0
Angular2 Get请求工作正常,但POST请求给我error.this是我的要求Angular2 Get请求工作正常,但POST请求给我的错误
url = environment.API + "products/";
headers = new Headers({ 'Content-Type': 'application/json' });
options = new RequestOptions({ headers: this.headers });
constructor(private http:Http) {
}
getProductsList(data): Promise<any> {
return this.http.post(this.url+'getproductsbyfilters', JSON.stringify(data), this.options).toPromise()
.then(this.extractData)
.catch(this.handleErrorPromise);
}
你得到的错误是什么? –
XMLHttpRequest无法加载http:// localhost:8090/api/front/products/getproductsbyfilters。对预检请求的响应不会通过访问控制检查:请求的资源上不存在“访问控制 - 允许来源”标头。因此不允许访问Origin'http:// localhost:4200'。 –
看起来像一个CORS问题,允许通过与您的服务器不同的来源访问POST方法(您的前端位于localhost:4200,而您的api位于localhost:8090,两个不同的来源) –