Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
myPromise is not a function

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!