Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda