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

123
Visualizações
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 à 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