I am unable to resolve a Promise that is created. Not sure where the problem is, please help me to resolve this.
const tsearch = async () => {
console.log("calling")
//requesting the relevant page data
await new Promise((resolve) => {
getData("wifi", 2, true);
return resolve("success")
});
console.log(finished);
}
function getData(url, callControl = 0, wifi = false) {
if (!!url) {
console.log(url + " - " + callControl)
}
if (callControl > 0)
setTimeout(getData, 1000, url, --callControl)
else {
console.log("getData - else part - resolving")
// Promise.resolve();
}
}
tsearch();