Is there a way to just tell the server to update data without subscribing? Skipping a return statement and a subscription seems to render the http call inert.
In my case, my DB guy created a bunch of stored procedures that return nothing and sometimes I want to do something simple like this in my service:
public setItem(item: IRequestItem) {
this.http.post('api/items', item);
}
and call it like this in my component:
save() {
var comp = this;
this.items.forEach(function(item) {
comp.service.setItem(item)
});
}
Instead I have to do something like this in the service:
public setItem(item: IRequestItem) {
return this.http.post('api/items', item);
}
And then call it like this in the conponent:
save() {
var comp = this;
this.items.forEach(function(item) {
comp.service.setItem(item).subscribe(r => console.log(r));
});
}
Which would return lots of these:
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 learning so maybe I'm looking at it wrong. Can I interpret something in that Response object that will let me know if the operation failed or succeeded? Or is there another syntax that will just return a success or failure instead of the confusing "No Content" response?