繁体   English   中英

从 Angular 请求时的 HttpErrorResponse

[英]HttpErrorResponse when requested from Angular

我的前端使用 angular,后端使用 golang/postgresql。 我正在从邮递员和角度发送完全相同的 json 有效负载。 它正在处理邮递员,但 angular 返回此错误:

ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error",...}

我尝试删除标题并添加它们,但没有任何改变。 我的代码:

在编辑页面:

   let json = JSON.stringify(session)
        console.log(json)
        this.httpService.updateSession(json).subscribe()

在 httpService 中:(请查看这里的评论)

 private headers: HttpHeaders;
  private accessPointUrl: string = "http://localhost:3001";

  constructor(private http: HttpClient) {
    this.headers = new HttpHeaders({
      "Content-Type": "application/json; charset=utf-8"
    });
  }

  public updateSession(payload) {
    console.log(payload) //I'm taking this payload from console, add it to postman, and everything works 
    return this.http.put(this.accessPointUrl+ '/updateSession', payload,{headers: this.headers}); //I tried removing the headers and playing with it
  }
}

从角度发送时,后端的错误显示为: pq: invalid input syntax for type timestamp: ""

我被卡住了,我真的无法弄清楚问题所在。 请帮助并感谢您。

正如我从pq: invalid input syntax for type timestamp: ""了解到的pq: invalid input syntax for type timestamp: ""您将错误的数据类型发送到postgresql数据库。 因此,首先,检查您发送的数据类型,然后再将它们输入到数据库中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM