Created
March 9, 2018 02:30
-
-
Save rafaelaugustos/85f8f839fa759d6312f9b4c06616bb2f to your computer and use it in GitHub Desktop.
Revisions
-
rafaelaugustos created this gist
Mar 9, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ // Login Api(){ this.setState({loading: true}) NetInfo.isConnected.addEventListener( 'connectionChange', (isConnected) => this.setState({internet: isConnected}) ) if(this.state.internet){ axios.post('https://localhost:8000/api/appcompras/login', { scheme_url: 'namine', email: this.state.email, password: this.state.senha }) .then(res => { console.log(res) this.setState({loading: false}) if(res.data.result.success){ this.setState({error: false}) AsyncStorage.setItem('@MySuperStore:dados', JSON.stringify(res.data)) AsyncStorage.setItem('@MySuperStore:token', "true") Actions.catalogo({}) }else{ this.setState({error: false}) Toast.show({ text: res.data.result.message, position: 'bottom', buttonText: 'Okay' }) } }) .catch(err => console.log(err)) }else{ this.setState({loading: false}) Toast.show({ text: 'Sem conexão', position: 'bottom', buttonText: 'Okay' }) } } // Catalogo componentDidMount(){ console.log(AsyncStorage.getItem('@MySuperStore:dados')) this.loadCatalogos() }