This commit is contained in:
João Borges 2019-01-27 16:32:04 +00:00
parent e6f6544df0
commit 8a3b49db15
2 changed files with 37 additions and 19 deletions

View File

@ -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

View File

@ -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;
});
};