Can I use SecureStorage getItemAsync except without async?

#1

I would like to store a token in secure storage, and load it into my app for authorization. My current problem is that my API call is being executed before the token loads, because the getItem method is async. Is there a non-async method that I can use with SecureStorage?

Thanks

#2

Hi

Becouse SecureStore.getItemAsync returns https://docs.expo.io/versions/latest/sdk/securestore.html#returns-1

u should use it in this way

SecureStore.getItemAsync(key).then((result)=>{
   Api Call
}).cath((error)=>{
 console.log(error)
})
#3

I guess I stated my issue too simply. I was attempting to retrieve multiple values from the SecureStore. I could separate each into it’s own function and cascade the function calls once one succeeds, but I would prefer to just wait for the value to be set.

#4

Almost all functions in Expo and React Native are async. It sounds like you might want to use Promise.all. Also learn how async/await work (in addition to the underlying promise APIs) if you’re unfamiliar with them.

2 Likes