Is there a way to return a ReasonPhrase and some plain text from aspnet core to Angular? I create a new record and return it's id to the client, along with a ReasonPhrase for Toastr.
I have this on my webapi controller:
[HttpPut("save")]
public async Task<IActionResult> Save(MyModel model)
{
model.Id = await _service.Save(model);
return Ok(new HttpResponseMessage
{
ReasonPhrase = $"Record saved",
Content = new StringContent(model.Id.ToString(), Encoding.UTF8, "text/plain"),
});...
And when I try to read it the content in Angular (8) like so:
save$.subscribe((result: any) => {
console.log(result.content);
I see this:
{headers: Array(1)}
headers: Array(1)
0:
Key: "Content-Type"
Value: ["text/plain; charset=utf-8"]
__proto__: Object
length: 1
__proto__: Array(0)
__proto__: Object
No idea what I'm doing wrong (is it even possible to do this?) but I want the value to be my newly created id but it's ["text/plain; charset=utf-8"] instead
