Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const httpLink = createHttpLink({
uri: GRAPHQL_API_ENDPOINT
})
const authMiddleware = setContext(async (req, { headers }) => {
const token = await AsyncStorage.getItem('token')
return {
headers: {
...headers,
Authorization: `Bearer ${token}`
}
}
})
const client = new ApolloClient({
link: from([authMiddleware, httpLink]),
cache: new InMemoryCache()
})
export default client