Below is my function to return SQL query result.
function getPriorityList(operatorId) {
try {
const result = Api.getApisDetail(operatorId);
return result;
} catch (error) {
console.log(error);
}
}
CodePudding user response:
you should wait for promise fulfillment
try this :
async function getPriorityList(operatorId) {
try {
const result = await Api.getApisDetail(operatorId);
return result;
} catch (error) {
console.log(error);
}
}
CodePudding user response:
It appears that the promise implementation is incorrect in this case. Try something along these lines:
function getPriorityList(operatorId) {
Api.getApisDetail(operatorId).then((result) =>{
console.log(result);
return result;
}).catch((error)=>{
return error;
});
}
The "Api.getApisDetail" function must also return promise in this case.