我对诺言并不了解。我想在满足条件时触发我的函数failresponse
。 failresponse
在用户屏幕上显示文本错误。并且,如果可能的话,我想避免触发函数getDataPDV
。我应该如何解决? else
代码正确无误。
谢谢。
if (nomProduit,pdvType,classeProduit,sousClasseProduit == "") {
geoCode(location).then(function(locationFromApi) {
getDataPDV(locationFromApi,nomProduit,sousClasseProduit)
.then(() => failResponse(res,requestBody.text));
});
} else {
geoCode(location).then(function(locationFromApi) {
getDataPDV(locationFromApi,sousClasseProduit)
.then(function(data) {
return successResponsev2(res,data);
})
.catch(() => failResponse(res,requestBody.text));
});
}