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