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

167
Visualizações
Why does bind fix "failed to execute 'fetch' on 'Window' illegal invocation" error?

I'm just curious,

This...

let s = { f: window.fetch };
s.f("https://www.google.com");

fails with

Failed to execute 'fetch' on 'Window': Illegal invocation

While this works...

let s = { f: window.fetch.bind(window) }; 
s.f("https://www.google.com");

How does the latter fix the issue? Is there any theory behind why it works that way?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

For some internal purpose, the fetch function must have this be the same as window. When you create your own object and just assign the fetch function as one of its properties, the fetch function has no access to the window object as this.

The fetch specification describes things the window might be used for. You might be able to make your original code work by setting no-window, but I have not tested that.

about 4 years ago · Juan Pablo Isaza Relatório
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