Angular: Getting response from a Http request

Im trying to figure out how to get a console message from the Http response
But i constantly get Red Error message in the console log even when the Http request seems to be succesfull


CreateItem(val: any){
  return + '/FoodItems/Create-Item', val,{ observe: 'response'});


      (val) => console.log("getting log value", val)

when i start CreateItem() it did add an object to the database so it seems like it is succesfull but i always get a red error message in the console.log :

core.mjs:6495 ERROR

1. HttpErrorResponse {headers: HttpHeaders, status: 200, statusText: ‘OK’, url: ‘https://localhost:44355/api/FoodItems/Create-Item’, ok: false, …}

I think i have found the problem
In the server:

the problem is with the returning Ok text
if i put text in the return i get a error

	return Ok("Succesfull uploaded");

when i do this :

	return Ok();

there is no error any more.
How can i make sure than when i put text in a returning type i dont get a error in Angular?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.