Angular 错误:未捕获(承诺中):URL:null状态:404的状态为0的响应

Angular 错误:未捕获(承诺中):URL:null状态:404的状态为0的响应,angular,typescript,ionic-framework,ionic3,typescript2.0,Angular,Typescript,Ionic Framework,Ionic3,Typescript2.0,当我试图点击一个post请求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/buil

当我试图点击一个post请求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)
我的打字脚本代码是

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);
        });
    });
  }

但是,当我试图在Postman应用程序上点击此url时,它正在工作,等待帮助。

以下是http post方法的签名

post(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;

您正在使用HttpClient吗?如果是这样,请删除“.map(res=>res.json())”,因为这是内部处理的。请检查this.db。它是否具有有效的URI或空值?@DeWetvanAs我仅使用Http,并且在删除“.map(res=>res.json())后尝试了此操作还是一样error@EhasanulHoque先生,我的this.db url是有效的,这有一个url,它在邮递员上给我回复,但不在这里。对不起,先生,我之前尝试过,但仍然不起作用。相同的错误再次出现。内容类型可能是application/json,这更具体。因为发送到服务器的数据是json格式的。
var options = new RequestOptions();
options.headers = new Headers();
options.headers.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),options).map(res=>res.json())
    .subscribe(res=>{
      console.log(res);
      resolve(res);
    }, (err) => {
      reject(err);
    });