Hi, on Android devices, using async await is not working for me. Am I the only one?
For example, getting a value from Capacitor’s Storage plugin is resolved with async await in the browser but not on Android
behavior on iOS: [log] - token {“token”:“abcd”,“fetchedAt”:“2020-04-12T20:01:35.721Z”}
behaviour on ionic serve
token {token: “abcd”, fetchedAt: “2020-04-12T19:03:29.765Z”}
wrong behavior on Android
Msg: token [object Object]if I do a {{webToken | json }} on the view, I get the _isScalar, blabla object
my capacitor version Capacitor Doctor
Latest Dependencies: @capacitor/cli: 2.0.1 @capacitor/core: 2.0.1 @capacitor/android: 2.0.1 @capacitor/ios: 2.0.1
You’re Idea should show you an Error. getStorage must return a Promise, like you correctly declared but you are not returning one. The simpelst Solution is replace JSON.parse( item . value )
with Promise.resolve(JSON.parse( item . value ));.
But make sure you return something anyway, as your current return is in an if, otherwise the other code will hang on the await for ever.
Hi, sorry, I was indeed returning an observable where I was testing this. Strange that it worked anyway in the other platforms. My bad. Thanks for the support