var data = 0;
NativeStorage.getItem('loginSession',(result)=>{
data = result;
},(err)=>{
console.log(err);
});
// I want here the new value of variable data
Just like I mentioned here, How to get the value at the end of the function. As Because I am requesting this function from another to get that particular value.. Like this
function a(){
var ntval = getmetheNativeValue();
console.log(ntval);
}
function getmetheNativeValue(){
var data = 0;
NativeStorage.getItem('loginSession',(result)=>{
data = result;
//And here if I try to return the data variable like return(data); not working as well
},(err)=>{
console.log(err);
});
//now here I need to return the new data value like this return(data); but this returning the old value as 0 not the new value.
}
Please any one tell me how to get the value in first function from the second one?
here is my asn function pleaes check whether I am going in the right direction or not
itemInCart:async(id)=>{
await NativeStorage.getItem('cartSession',(result)=>{
if(result==''){
returns= 0;
//return returns;
}else{
var split = result.split(';');
for(var i=0;i<split.length;i++){
var split_again = split[i].split('-');
if(split_again[0]==id){ console.log('true event');
returns= 1;
//return returns;
}
}
returns= 0;
//return returns;
}
},()=>{
returns= 0;
//return returns;
});
return returns;
}