【问题标题】:angular 7 http post work on edge and firefox but return error on chromeangular 7 http post在edge和firefox上工作,但在chrome上返回错误
【发布时间】:2019-05-02 09:19:56
【问题描述】:

http post 在 chrome 浏览器上不工作,但在 firefox 和 edge 上工作正常

我有一个带有 angular7 和 netcore 2.2 的应用程序,crud 示例在所有浏览器中都可以正常工作,除了保存方法(具有 http.post)在 chrome 上不起作用

 save(user: UserModel): Observable<ResponseObj> {
    const body =   JSON.stringify(user);
    const headers = new Headers({ "Content-Type": "application/json" });
    const options = new RequestOptions({ headers: headers });
    return this._http.post("/api/Users/Save", body, options)
      .pipe(map(res => res.json()))
      .pipe(catchError(this.handleError));
  }

我希望调用服务器 api 并创建新用户

【问题讨论】:

  • 能否为 chrome 中出现的错误添加屏幕截图?
  • 您遇到的错误是什么?
  • 请清除 chrome 中的缓存
  • 出现错误:SyntaxError: Unexpected token

标签: angular http-post


【解决方案1】:

试试这个:

return this._http.post("/api/Users/Save", body, options)
    .subscribe((resp: any) => {
        }, error => {
            this.handleError
        }
     )

【讨论】:

    猜你喜欢
    • 2017-03-08
    • 2014-05-11
    • 2017-01-12
    • 2016-04-11
    • 1970-01-01
    • 1970-01-01
    • 2017-03-10
    • 1970-01-01
    • 2018-06-14
    相关资源
    最近更新 更多