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

119
Vistas
Javascript returning Promise Result value

What do I need to do to adjust the way this method returns to only return the value and not the Promise?:

function getCacheValue(toMatch){
     return caches.open("v1.1::Custom").then(cache=>{ cache.match(toMatch).then(result=>result).then(resultValue=>resultValue);});
}

Essentially what I would like it to return is the Response from case.match(). I'm still pretty new to asynchronous Promises, Everything I've tried ends up returning a Promise rather than the result of the Promise. I've also tried wrapping the caches.open call in a new Promise((res, rej){caches.open.....}) and calling res(resultValue) and also tried Promise.resolve(...) but I still can't seem to just get resultValue to return.

I'm pretty sure the issue here is the synchronous function is trying to get the result of an asynchronous call but I am fairly certain that should still be possible to accomplish.

Also, I would prefer the getCacheValue function to remain synchronous as I will end up synchronously sending different values into it if the result is null from the first call.

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