我将Angular 4与RxJS 6一起使用。我对Microsoft qnA Maker服务的HttpClient POST被浏览器取消。我尝试添加Access-Control-Allow-Origin,但是没有用。
在chrome中启动http请求时,在浏览器控制台的“网络”标签中,我看到状态为“ cancelled”的失败http请求。而在边缘,我根本看不到该http请求的任何日志。
import { Component, OnInit } from '@angular/core';
import { map } from 'rxjs/operators';
import { HttpClient, HttpHeaders,HttpErrorResponse,HttpParams } from '@angular/common/http';
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'XXXX'
})
};
let body = JSON.stringify({ question: "postedQuestion"});
return this.http.post(qurl,{params},{ headers: headers }).pipe(map(data => {})).subscribe(result => { console.log(result); });