Angular 松弛API角度积分200误差,带';正常响应';

Angular 松弛API角度积分200误差,带';正常响应';,angular,typescript,http,slack,Angular,Typescript,Http,Slack,我正在尝试创建一个与我的angular应用程序通信的Slack应用程序,我觉得我很快就能让它工作了,但我发现以下错误: 下面是我在angular应用程序中调用webhook的方式: this.http.post<any>(webHook, JSON.stringify(message), options).subscribe(res => { console.log('res' + res); return res; }); // err

我正在尝试创建一个与我的
angular
应用程序通信的
Slack
应用程序,我觉得我很快就能让它工作了,但我发现以下错误:

下面是我在
angular
应用程序中调用webhook的方式:

   this.http.post<any>(webHook, JSON.stringify(message), options).subscribe(res => {
      console.log('res' + res);
      return res;
    }); // error here about json at 0 with ok response and 200 http

服务器返回的答案是正确的,但返回时很可能会返回字符串,这将导致其为false。 从服务器正确返回信息的示例:

巴肯德:

return OK('wellcome'); /// return {status:200,ok:false}
// This is a mistake and you should send the information as follows
string data='wellcome';
return Ok(data) // {status:200,ok:true}

解决方案是将请求的
resonsetype
更改为
'text'
,因为它希望得到
JSON
响应

this.http.post(webHook, JSON.stringify(message), {headers, responseType: 'text'}).subscribe(res => {
  console.log('res' + res);
  return res;
});

似乎您正在尝试解析一个已经存在的JSON对象?你能添加拦截器代码吗?@ApoorvaChikara我已经添加了拦截器,如果我一起删除拦截器,我仍然会得到错误,因此认为它不是来自这里,我无法编辑服务器代码,因为它来自slack api
this.http.post(webHook, JSON.stringify(message), {headers, responseType: 'text'}).subscribe(res => {
  console.log('res' + res);
  return res;
});