I want to set the value of the result to the promise variable, which is JSON file.
I tried returns, creating the variable like (result) => {var myVar = result}
async function getUpdate() {
async function getFirstEvent() {
//code returning a JSON
}
async function getSecondEvent() {
//code returning a JSON
}
let firstPull = await getFirstEvent(); //unimportant
var dataPull1 = await JSON.stringify(firstPull); //unimportant
var promise = new Promise(async function(resolve, error) {
let secondPull = await getSecondEvent();
var dataPull2 = await JSON.stringify(secondPull);
setTimeout(() => resolve(dataPull2), 3000);
}).then((result) => {
//return a value to promise ???
});
}
getUpdate();
setInterval(getUpdate, 5000);
I've received undefined
, but that's because of the variable didn't get any value assigned to.