Skip to content

Instantly share code, notes, and snippets.

Forked from kensmash/Apollo Afterware Async attempt
Last active July 8, 2020 18:48
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
const setTokenAfterware = new ApolloLink(async (operation, forward) => {
return forward(operation).map(async res => {
const context = operation.getContext();
const { response: { headers } } = context;
const token = headers.get["x-token"];
const refreshToken = headers.get["x-refresh-token"];
if (token) {
await AsyncStorage.setItem("token", token);
if (refreshToken) {
await AsyncStorage.setItem("refreshToken", refreshToken);
return res;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment