In Ionic, I have two functions. The first should be called while the script is loading, and the second should be called after it.
import * as testao from "src/assets/js/Script"
async functionToCall(){
await this.firstFunction();
this.secondFunction();
}
async firstFunction() {
let script = document.createElement('script');
script.onload = () => {
// perform actions you need on load of the script
this.carts();
}
script.src = "https:***.js";
script.onerror = () => {
};
document.body.appendChild(script);
}
carts() {
testao.testFunc()
}
secondFunction(){
}
I tried return Promise and async with await, but neither worked.