Reputation: 129
I have a simple app - code at this GitHub repository. In the App.js
file, I use a method called Backend.getUser()
, which simply gets the The user
object from AsyncStorage
as a string. So, if the object exists, the user should be taken to the Home screen without waiting at the login screen. If not, the login screen is displayed. This can be seen in this file.
The problem is, instead of doing this, I get a warning in the console; and the app remains on the login screen, even if the user
object exists.
The warning:
[Unhandled promise rejection: SyntaxError: JSON Parse error: Unrecognized token '<']
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:25 in <unknown>
- ... 8 more stack frames from framework internals
Upvotes: 0
Views: 588
Reputation: 3426
Replace your getUser function By below code
getUser(){
return AsyncStorage.getItem('@Trail:user').then((itemValue)=>{
return itemValue
})
}
Upvotes: 1