The following code is not waiting for the else part to return data before resolving.
Where I'm going wrong with this code?
return request.get(`${<URL1>}`)
.then((res) => {
if (res1.data[0]) {
data1 = res.data[0]};
} else {
request.get(`${<URL2>`)
.then((res2) => {
data1 = res2.data
});
}
return Promise.resolve(data1);
})
Thanks in advance.
San