38 lines
943 B
JavaScript
38 lines
943 B
JavaScript
/**
|
|
* @format
|
|
*/
|
|
|
|
import 'react-native-gesture-handler';
|
|
import { AppRegistry, YellowBox, AsyncStorage } from 'react-native';
|
|
import App from './App';
|
|
import { name as appName } from './app.json';
|
|
import axios from "axios";
|
|
|
|
|
|
YellowBox.ignoredYellowBox = ['Warning: Each', 'Warning: Failed'];
|
|
console.disableYellowBox = true;
|
|
|
|
getAuthToken = () => {
|
|
return new Promise(async (resolve, reject) => {
|
|
|
|
try {
|
|
const data = await AsyncStorage.getItem('persist:root');
|
|
resolve(JSON.parse(data))
|
|
} catch (error) {
|
|
reject(error)
|
|
|
|
}
|
|
|
|
})
|
|
};
|
|
|
|
(async () => {
|
|
const authToken = await getAuthToken();
|
|
const auth = JSON.parse(authToken.authKeyReducer);
|
|
console.log("AUTHTOKEN", auth);
|
|
axios.defaults.headers.common['Authorization'] = `${auth.authKey.token_type} ${auth.authKey.access_token}`;
|
|
|
|
})();
|
|
|
|
AppRegistry.registerComponent(appName, () => App);
|