My promise isn't being invoked like I expect it to and as it does do on w3schools.
I'm using this code from w3schools as a reference:
<script>
async function myDisplay() {
let myPromise = new Promise(function(resolve) {
setTimeout(function() {resolve("I love You !!");}, 3000);
});
document.getElementById("demo").innerHTML = await myPromise;
}
myDisplay();
</script>
This is my code:
firstResult(){
console.log('het werkt');
async function myDisplay() {
let myPromise = new Promise(function(resolve) {
setTimeout(function() {resolve('');}, TIMEOUT_GLOBAL);
});
this.result = await myPromise;
}
myDisplay();
},
I somehow get the error 'myPromise is not a function'
I want this.result to be assigned the returned value (''). The w3 example ('I love You !!') actually gets displayed on the page so I wonder why mine says the promise isn't a function.
Could someone help me out?