Created
June 2, 2016 18:28
-
-
Save czbaker/2d21139fb711586d1bbb931a71fd262a 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
| import ApolloClient, { createNetworkInterface } from 'apollo-client'; | |
| const networkInterface = createNetworkInterface('/graphql'); | |
| networkInterface.use({ | |
| applyMiddleWare(req, next) => { | |
| if (!req.options.header) { | |
| req.options.header = {}; // Create the header object if needed. | |
| } | |
| req.options.header.authorization = localStorage.getItem('token') ? localStorage.getItem('token') : null; | |
| next(); | |
| } | |
| }); | |
| const client = new ApolloClient({ | |
| networkInterface, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment