【发布时间】:2018-05-04 02:58:47
【问题描述】:
所以我不断收到此错误:
在我的其他 Angular 项目中,我在任何 POST 或 GET 请求之前向名为 OPTIONS 的服务器发送了一个预检请求,我注意到在这种情况下它丢失了,并且服务器正确响应了请求,但我无法访问它,因为错误被抛出,我无权访问数据。
我的服务有下一个实现:
login(user) {
const headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
const body = new URLSearchParams();
body.set('grant_type', 'password');
body.set('username', user.username);
body.set('password', user.password);
return this._http.post('http://thevotechain.azurewebsites.net/Token', body, { headers: headers })
.map((response: Response) => {
return response.json();
});
}
帮助。
【问题讨论】:
-
后端 API 使用什么。哪种语言,服务器?
-
@AshishRanjan 我们正在使用 ASP .NET