【问题标题】:Http failure during parsing for url解析 url 期间的 Http 失败
【发布时间】:2019-01-08 15:44:48
【问题描述】:

login.ts

onLogin() {
  let input = new FormData();
  input.append('email','ajith@gmail.com')
  input.append('password','12356789')
  this.http.post('http://worthyconsultants.in/training/api/v1/user/login',
  input,{responseType: 'json'}).subscribe(res=>{
    console.log(res)
     },
      err=>{
    console.log(err)
    }) 
   }

这是我的登录功能,但响应是错误的。说解析错误

【问题讨论】:

  • 您确定响应类型是 JSON 吗?它看起来像一个php数组
  • @AndreiDumitrescu-Tudor 是的,添加了邮递员回复
  • 你也可以在邮递员中显示响应头吗?
  • 响应不是 JSON。试试这个标题{ 'Content-Type':'application/json'}
  • @AndreiDumitrescu-Tudor 添加

标签: json angular


【解决方案1】:

首先,您使用 POSTMAN 工具确认您的发布请求,如果是,请点击此链接,它对您有帮助,或者可能是后端问题 [在此处输入链接描述][1]

https://www.youtube.com/watch?v=HgKx36cpu60

【讨论】:

    【解决方案2】:

    后端代码中有一个打印语句,这就是为什么它在邮递员漂亮视图中看起来很好。

    【讨论】:

      猜你喜欢
      • 2019-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-06
      • 1970-01-01
      • 2020-10-13
      相关资源
      最近更新 更多