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

173
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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