我正在尝试在我们的API( 由kong API发送 )调用返回的错误402上收到错误消息,但我的事务服务正在捕获错误浏览器显示错误HTTP 402时的HTTP 504。
It shows an Error 402 with a proper response, but my error message is showing as an Error 504
我的httpClient调用如下:
sendCashOutRequest(transaction: Transaction): Promise<{ success: boolean, msg: string }> {
let success = false;
console.log("generating send request ...");
const authUrl = environment.authAPI;
const remittanceUrl = environment.sendMoneyAPI;
const remittanceRequestBody = this.buildRemittanceRequestBody(transaction);
this.showLoader();
let resultToken;
let sendPromise = new Promise<{ success: boolean, msg: string }>( (resolve,reject) => {
//this will post to get authentication token
this.authBearerService.getAuthToken().then( token => {
resultToken = token
console.log("First API call (auth request) : " + resultToken);
return this.http.post(remittanceUrl, remittanceRequestBody, {
observe: 'response',
headers: new HttpHeaders()
.set('Content-Type', 'application/json')
.set('Authorization', 'Bearer ' + resultToken),
responseType: 'json'
} ).toPromise()
.then(
resp2 => {
console.log("Successfully sent transfer request!", resp2);
//get response body
success = true;
this.hideLoader();
resolve( {success: success, msg: transaction.PayRefNo});
},
err => {
console.warn("Error encountered!!");
console.warn("has message body? ",err.body['message']);
reject( { success, msg: err.error.message });
}
).catch( err => {
console.log("Error in sending cash out request", err);
reject( {success : success, msg : "Error connecting to Seven Connect services, Please try again"});
});
});
});
return sendPromise;
}
浏览器和角度之间是否有某种东西它赢得了+无法捕获错误402?或者我是否错误地链接了我的帖子请求?