rein
11/27/2017, 9:21 AMmimica
11/27/2017, 9:26 AMimport { setContext } from "apollo-link-context";
import { ApolloLink, split ,from } from 'apollo-client-preset'
const httpLink = new HttpLink({ uri: 'SIMPE_ENDPOINT_URL' })
const authMiddleware = new setContext(operation => {
AsyncStorage.getItem("token").then(token => {
return {
headers: {
Authorization: `Bearer: ${token}` || null
}
};
});
});
const client = new ApolloClient({
link: from([authMiddleware, httpLink]),
cache: new InMemoryCache()
})
rein
11/27/2017, 9:27 AMmimica
11/27/2017, 9:31 AMrein
11/27/2017, 9:32 AMrein
11/27/2017, 12:58 PMpbandjs
02/19/2018, 5:28 PMpbandjs
02/19/2018, 5:29 PM