teste
This commit is contained in:
parent
e6f6544df0
commit
8a3b49db15
|
@ -18,6 +18,9 @@ import Router from './Router'
|
|||
import Login from './screens/Login'
|
||||
import {AsyncStorage, ActivityIndicator} from 'react-native';
|
||||
import AuthLoadingScreen from "./screens/AuthLoading";
|
||||
import {getToken} from "./Helpers/Requests";
|
||||
|
||||
|
||||
|
||||
export default class App extends Component {
|
||||
|
||||
|
@ -37,28 +40,12 @@ export default class App extends Component {
|
|||
}
|
||||
|
||||
//componentDidMount() is invoked immediately after a component is mounted
|
||||
/*componentDidMount() {
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
AsyncStorage.removeItem('firstLogin');
|
||||
console.log('oi - ' + getToken('TC2MT8QFJT', '80f3b6e5'));
|
||||
|
||||
AsyncStorage.getItem('firstLogin').then((value) => {
|
||||
|
||||
console.log('aqui')
|
||||
if (value == null) {
|
||||
//setItem (key: string, value: string)
|
||||
deviceStorage.saveItem('firstLogin', JSON.stringify(true));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
//this.setState({firstLogin: false});
|
||||
}
|
||||
|
||||
this.setState({loading: false});
|
||||
|
||||
})
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
//Buttons do Intro Slider
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
const axios = require('axios');
|
||||
|
||||
const url = "http://enei2019.uingress.com/internal/api/token";
|
||||
|
||||
export function getToken(userName, password) {
|
||||
|
||||
let headers = {
|
||||
header: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
};
|
||||
|
||||
let request = {
|
||||
method: 'GET',
|
||||
headers: headers,
|
||||
body: {
|
||||
username: userName,
|
||||
password: password,
|
||||
grant_type: 'password'
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, request).then(response => {
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log('There has been a problem with your fetch operation: ' + error.message);
|
||||
// ADD THIS THROW error
|
||||
throw error;
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue