Is there a way to simply tell the server to update data without a subscription? Skipping the return statement and subscription seems to make an inert HTTP call.
In my case, my guy from the database created a bunch of stored procedures that do not return anything, and sometimes I want to do something simple, like this in my service:
public setItem(item: IRequestItem) { this.http.post('api/items', item); }
and name it as follows:
save() { var comp = this; this.items.forEach(function(item) { comp.service.setItem(item) }); }
Instead, I should do something similar in the service:
public setItem(item: IRequestItem) { return this.http.post('api/items', item); }
And then name it like this:
save() { var comp = this; this.items.forEach(function(item) { comp.service.setItem(item).subscribe(r => console.log(r)); }); }
Which would return a lot of them:
Response {_body: "", status: 204, ok: true, statusText: "No Content", headers: Headersโฆ} _body : "" headers : Headers ok : true status : 204 statusText : "No Content" type : 2 url : "http://localhost:56018/api/items" __proto__ : Object
I'm just studying, maybe I'm looking at it wrong. Can I interpret something in this Response object that will let me know if the operation failed or succeeded? Or is there another syntax that simply returns success or failure instead of the confusing "No content" response?
Methodician
source share