Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!