Created
March 24, 2018 13:04
-
-
Save njwest/f56bee187cb7a0bfd93a0bdbe6db1aec to your computer and use it in GitHub Desktop.
services/deviceStorage.js loadJWT()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AsyncStorage } from 'react-native'; | |
const deviceStorage = { | |
# code removed for brevity | |
async loadJWT() { | |
try { | |
const value = await AsyncStorage.getItem('id_token'); | |
if (value !== null) { | |
this.setState({ | |
jwt: value, | |
loading: false | |
}); | |
} else { | |
this.setState({ | |
loading: false | |
}); | |
} | |
} catch (error) { | |
console.log('AsyncStorage Error: ' + error.message); | |
} | |
}, | |
# snip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment