angular - Slack API Angular Integration 200 错误并带有“OK 响应”
问题描述
我正在尝试创建一个Slack
与我的应用程序通信的angular
应用程序,我觉得好像我非常接近让它工作但是我收到以下错误:
以下是我在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
我在正确的Slack
频道中看到了通知,但是因为我的角度应用程序中有一个错误拦截器,所以错误导致我的角度应用程序出现问题,非常感谢任何帮助。
错误拦截器.ts:
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// console.log('request was intercepted by error');
return next.handle(req)
.pipe(
// Retry on failure
retry(2),
// Handle errors
catchError((error: HttpErrorResponse) => {
console.error(error);
let errorMessage = 'An unknown error occurred!';
if (error.error.message) {
errorMessage = error.error.message;
}
this.dialog.open(ErrorComponent, {data: {message: errorMessage}});
this.errorService.throwError(errorMessage);
return throwError(error);
}));
}
解决方案
答案是从服务器正确返回的,但是返回时很可能会返回一个字符串,这会导致它为假。从服务器正确返回信息的示例:
烘焙:
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}
推荐阅读
- pandas - 未来警告:不推荐将 datetime64-dtype 数据传递给 TimedeltaIndex
- azure-devops - 在步进条件下使用矩阵环境变量的 Azure 管道
- reactjs - 数据只有在预先有空白行时才进入反应数据网格
- java - 内存不足时的 Java EE 堆转储
- ansible - 创建使用 root 的幂等 playbook 然后禁用 root 服务器访问
- c# - Twitter API 授权问题 - 401 错误
- ruby-on-rails - 在旧版 Rails 应用程序中安装 webpacker
- flutter - Flutter 使用 Base64 或其他 MP3 编码器/解码器
- java - 如何在像whatsapp或skype这样的recyclerview中实现淡出stickyheader?
- java - 如何将数据加载到recyclerView