Skip to content

Instantly share code, notes, and snippets.

@ChettaDarkkill
Last active September 5, 2018 08:24
Show Gist options
  • Save ChettaDarkkill/9555c001e8f3a2440a27425072cb5f62 to your computer and use it in GitHub Desktop.
Save ChettaDarkkill/9555c001e8f3a2440a27425072cb5f62 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { AsyncStorage } from 'react-native';
import axios from 'axios'
import join from 'url-join'
axios.interceptors.request.use(async (config)=> {
const jwtToken = await AsyncStorage.getItem("token")
if (jwtToken != null) {
config.headers = { 'x-access-token': jwtToken }
}
config.url = join('http://demo.com/api/v1', config.url);
return config;
});
export const httpClient = axios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment