Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda