@ricardofvallejo6969 wrote:
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 AndroidUsage example:
I have a storage.service.ts with the following:
export
async
function
getStorage
(key
:
string)
:
Promise<any> {
const item = await Storage.get({ key: key })
;
if
(
!item
.
value
||
item
.
value
!==
'undefined') {
return
JSON.parse(
item
.
value
);
}
}
And then on my page, for example:
webToken:
string;
async
ngOnInit
() {
const token = await getStorage(
'token'
)
;
console.log('token', token)
}
and in the “run console” on android studio I get
I/Capacitor/Console: File:
http://192.168.1.4:8100/pages-login-login-module.js
- Line 134 - Msg: token [object Object]
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 objectmy 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
Posts: 1
Participants: 1