一旦我单击按钮将消息提交给 slack,我就会收到以下错误消息。但是,该消息已成功发送到松弛通道。该错误在 subscribe 方法上起作用。我尝试删除 subscribe 方法,但由于 observable 没有它就无法运行,我不得不使用它。
错误信息:
HttpErrorResponse {headers: HttpHeaders, status: 200, statusText: "OK", url: "https://hooks.slack.com/services/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", ok: false, …} .
error:{error: SyntaxError: Unexpected token o in JSON at position 0 at Object.parse (<anonymous>) at XMLHt…, text: "ok"} .
headers:HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ} .
message:"Http failure during parsing for https://hooks.slack.com/services/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" .
name:"HttpErrorResponse"
ok:false
status:200
statusText:"OK"
Angular4代码:
const payload = JSON.stringify({"text": "Hihi",});
const headers = new HttpHeaders().set('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
this.http.request(
'POST',
"https://hooks.slack.com/services/TOKEN",
{
'body': payload,
'headers': headers,
}
).subscribe();