React Native AsyncStorage getItem returns promise not value

前端 未结 2 1352
无人共我
无人共我 2021-02-14 15:32

I have a login form and I am able to post my the form values. After a successful POST request, I get authentication token returned from the API. I need to save this token for fu

相关标签:
2条回答
  • 2021-02-14 16:03

    You have to call as

    getUserToken().then(res => {
        console.log(res);
      });
    

    Since this is an async call.

    0 讨论(0)
  • 2021-02-14 16:10

    using Async/Await :

    async _getStorageValue(){
      var value = await AsyncStorage.getItem('ITEM_NAME')
      return value
    }
    
    0 讨论(0)
提交回复
热议问题