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

223
Vistas
API Cache Javascript my caching code doesn't work

i'm working on javascript code and i want to cache http GET request to API Pixabay. Problem the caching doesn't seem to work at all. Datas are always null. I can put a sample of code maybe someone will see something wrong about my code :

if ('caches' in window){
const newCache = await window.caches.open('cache-pixabay');

const options = {
    method: "GET",
    headers: new Headers({
        'Accept': 'application/json',
    }),
  }  

  let request = new Request(URL, options);
  datas = await newCache.match(request);
  alert(JSON.stringify(datas));
if(isEmptyObj(datas)) {
   alert('iciii');
    await newCache.add(request);
    datas = await newCache.match(request);
    alert(JSON.stringify(datas));
}

} else {
    xhttp.open("GET", URL, false);
    xhttp.send();
    datas = JSON.parse(xhttp.responseText);
}

Alert always displays {} null object Response. Need some tips. It lacks of example on internet.

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