import {create, isCancel} from 'apisauce';
import {Platform} from 'react-native';
import SInfo from 'react-native-sensitive-info';
const rax = require('retry-axios');

const api = create({
  baseURL: '',
  timeout: Platform.OS === 'ios' ? 6000 : 2500,
});
SInfo.getItem('token', {
  sharedPreferencesName: 'token',
  keychainService: 'myToken',
}).then(value => {
  api.setHeader('Authorization', `Bearer ${value}`);
});
SInfo.getItem('domain', {
  sharedPreferencesName: 'domain',
  keychainService: 'myDomain',
}).then(value => {
  api.setBaseURL(value);
});

export default api;
