我試圖與x-www-form-urlencoded
內容類型頭中的POST請求如下POST請求:HttpClient的使用x-www-窗體-urlencoded
login(username, password): Observable<any> {
return this.http.post('/login', {
username: username,
password: password
},
{
headers: new HttpHeaders()
.set('Content-Type', 'x-www-form-urlencoded')
}
);
不幸的是我的API說,我送空的用戶名和密碼。
因此,我決定向我的登錄端點發出郵遞員請求,並查看問題來自何處,並且郵遞員請求確實返回了用戶名和密碼。
當我從postman發佈我的API時,如何返回我的用戶名和密碼,當我從我的Angular應用程序發佈時,我的API返回空值?有什麼我失蹤?
應該是'application/x-www-form-urlencoded' – goat
經過大量的搜索這個解決方案的工作!很多舊的指南使用舊的HttpClient ... :)謝謝! – Marius
考慮這個解決方案https://stackoverflow.com/a/39864307/4420532 – Felix