我正在嘗試使用 post request 在 Angular 中實作 API,API 在 Postman 中運行良好,但是當我在 Angular 資料中實作此 API 時沒有發布,也沒有給我任何錯誤,我也檢查了我的網路!
我在瀏覽器中得到回應
{"code":204,"success":"Client Id is not selected!"}
狀態碼:200 ok
郵遞員中的有效載荷:
{"clientid": "D0242"}
有效載荷顯示在我的瀏覽器中:

應用程式設定
public static DigestEmailIdPrint = "articles/DigestEmailIdPrint";
服務.ts
DigestEmailIdPrint(clientid) {
return this.http.post<any>(
this.SERVERURL this.AppSettings.DigestEmailIdPrint,
{ clientid: clientid }
);
}
應用程式.ts
ngOnInit(){
this.DigestEmailIdPrint()
}
DigestEmailIdPrint() {
var postData = {
clientid: localStorage.getItem("storageselectedclient"),
};
this.article.DigestEmailIdPrint(postData).subscribe(
(res) => {
console.log(res);
console.log("hio");
if (res.message != "No Record Found") {
this.DigestEmailIdPrint = res;
}
},
(err) => {
console.log(err);
}
);
}
uj5u.com熱心網友回復:
嘗試將您的代碼更新為,因為 API 正在等待{ clientid: clientid }不{clientid : { clientid: clientid }}
DigestEmailIdPrint(payload) {
return this.http.post<any>(
this.SERVERURL this.AppSettings.DigestEmailIdPrint,
payload
);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/487454.html
