Created
December 30, 2017 13:52
-
-
Save maticzav/beef4f75838d423c2031c62cf702cac4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const authLink = new ApolloLink(async (operation, forward) => { | |
const token = await AsyncStorage.getItem('token') | |
operation.setContext(({ headers = {} }) => ({ | |
headers: { | |
...headers, | |
Authorization: token ? `Bearer ${token}` : null | |
} | |
})) | |
return forward(operation) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment