Angular HttpClient无法获取响应
我无法获取此post请求的任何服务器响应:Angular HttpClient无法获取响应,angular,angular-httpclient,Angular,Angular Httpclient,我无法获取此post请求的任何服务器响应: this.httpClient .post(this.appConfigService.buildAuthorizationUrl('/logon'), data, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, //observe: 'response',
this.httpClient
.post(this.appConfigService.buildAuthorizationUrl('/logon'), data, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
//observe: 'response',
})
.toPromise()
.then(
(response: any) => {
// not reached
},
(error: any) => {
// not reached
}
)
.catch(ex => {
// not reached
});
更新:
Fiddler显示了我希望在
。然后
成功块:
服务器响应示例:
HTTP/1.1 400 Bad Request
Cache-Control: no-cache,no-cache, no-store, must-revalidate
Pragma: no-cache,no-cache
Content-Type: application/json;charset=UTF-8
Expires: -1,0
Server: Microsoft-IIS/10.0
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcS2F5IFphbmRlclxEb2N1bWVudHNcZXZlXFNvdXJjZVxJbmZvcnNIVC5HZW5lc2lzQXBpXGxvZ29u?=
X-Powered-By: ASP.NET
X-UA-Compatible: IE=edge
Date: Wed, 30 Oct 2019 10:33:16 GMT
Content-Length: 79
{"error":"Error","error_description":"The user name or password is incorrect."}
更新
这可能是因为标题吗
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
而不是
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
背景:
我正在将现有的angularjs应用程序迁移到angular,我使用相同(未更改)的API问题是由CORS问题引起的似乎提供的用户名和密码不正确问题说明了所有问题“{”错误“:“错误”,“错误描述”:“用户名或密码不正确”。}”您是否使用了正确的凭据?请检查您作为
数据发送的内容。显然这是错误的。显然我需要澄清一些用户->更新