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

324
Views
localForage Indexdb in angular should work synchronous rest code should wait

In existing code I want to use localForage but my problem is that localForage is asynchronous but existing code is synchronous. below is the sample code.

var testValue="Test value";
 var testKey="TestKey";
 localForage.setItem(testKey, testValue);
 
 var valueFromLocalForage="";
 localForage.getItem(testKey).then(function(data){
        valueFromLocalForage=data;
        console.log(valueFromLocalForage);
 });
 
 //other code
 console.log(valueFromLocalForage);

first it print blank after that it print the value from localforage.

I want my other code should wait, I don't want to change whole code. I can't use async and await because calling method is not async. I am using angular. Please suggest

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!