I am looking at a way to try and nest promises. There seems to be an issue where I have two apis that keeping flopping back and forth. What I mean is, when the page loads a api will give me a 200, and the other gives me a 500 error. However, if I refresh the page then the successful api will fail and the other one will be successful. I want so that one api is not called until the other is called first. Here is what I have.
initTable() {
const hiPromise = new Promise((resolve, reject) => {
resolve(AHMan.getAppHi())
});
hiPromise.then((values) => {
console.log("the values here are", values);
approvalHi = values
}).
I know this works and gets the values back from my hi api. However, issue is try to nest the promises so that the second promise only happens after the first one. I tried this
initTable() {
const hiPromise = new Promise((resolve, reject) => {
resolve(AHMan.getAppHi())
})
hiPromise.then((values) => {
console.log("the values here are", values);
approvalHi= values
}).then(AHMan.getApprov()).then((approvalValue) => {
console.log(approvalValue);
approvalList = approvalValue
})
},
However, this doesnt seem to work. Any suggestions?