I keep encountering an error whenever I try to hit a post request URL:
Error: Uncaught (in promise): Response with status: 0 for URL: null
at c
(http://localhost:8100/build/polyfills.js:3:19752)
at c
(http://localhost:8100/build/polyfills.js:3:19461)
at http://localhost:8100/build/polyfills.js:3:20233
at t.invokeTask
(http://localhost:8100/build/polyfills.js:3:15660)
at Object.onInvokeTask
(http://localhost:8100/build/vendor.js:5125:33)
at t.invokeTask
(http://localhost:8100/build/polyfills.js:3:15581)
at r.runTask
(http://localhost:8100/build/polyfills.js:3:10834)
at o
(http://localhost:8100/build/polyfills.js:3:7894)
at e.invokeTask [as invoke]
(http://localhost:8100/build/polyfills.js:3:16823)
at p
(http://localhost:8100/build/polyfills.js:2:27648)
Here is my TypeScript code:
public getCategory(){
console.log('test');
return new Promise((resolve, reject) => {
let header = new Headers();
header.append('Content-Type', 'application/x-www-form-urlencoded');
let curr_page = { "currentPage":1,"pageSize":2 };
// var page_size = 5;
this.http.post(this.db,JSON.stringify(curr_page),{headers: header}).map(res=>res.json())
.subscribe(res=>{
console.log(res);
resolve(res);
}, (err) => {
reject(err);
});
});
}
Interestingly, when I attempt to test the same URL on Postman app, it works perfectly. Seeking assistance!