I am getting really stuck with an angular js HTTP post.
I have been using AngularJs in this particular project for nearly two years, and have never had this issue, it is also identical to other code, that is working in a lot of other places. I am lost, can anybody see anything I might be missing.
The server side code is running and working as I expect. One of my first thoughts was maybe I was not await
-ing something, and it was returning something incomplete, but that doesn't seem to be true.
I ran the same post using Postman, and the response was 9503
which I am perfectly happy with, so I don't think the problem is anything on the server side.
I am adding some code snippets (debugs were added to try and see what was going on)
function in the controller:
post() {
debugger;
this.loading++;
this.service.post(this.functionImport)
.then(r => this.postComplete(r),
ex => {
debugger;
this.exception = ex
})
.finally(() => this.loading--);
}
(I usually use promise.then().catcht()
but I wanted to see if this made a difference)
The function in the service:
post(model: FunctionImport): ng.IPromise<number> {
const url = './api/FunctionImports/Import';
return this.$http.post(url, model).then((r: ng.IHttpPromiseCallbackArg<number>) => {
debugger;
return r.data;
});
}
The exception that it catching on the promise
Object {data: null, status: -1, config: Object, statusText: "", headers: function}
Some headers in the post, from the Network tab in Chrome
Accept:application/json, text/plain, */*
Content-Type:application/json;charset=UTF-8
Origin:http://localhost:5001
Referer:http://localhost:5001/Admin.aspx?Page=FunctionImport
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36
X-Requested-With:XMLHttpRequest