SHARE
TWEET

Untitled

a guest Jun 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3.  
  4. import App from './App';
  5.  
  6. import ApolloClient from "apollo-boost";
  7. import { ApolloProvider } from "react-apollo";
  8.  
  9. let session = localStorage.getItem("session");
  10. let authorization = "";
  11. if(session) {
  12.     let sessionObj = JSON.parse(session);
  13.     authorization = sessionObj.access_token
  14. }
  15.  
  16. const graphQLServerURL = process.env.REACT_APP_API_URL;
  17. const client = new ApolloClient({
  18.     uri: graphQLServerURL + "/graphql",
  19.     headers: {
  20.        authorization,
  21.     }
  22. });
  23.  
  24. ReactDOM.render(
  25.     <ApolloProvider client={client}>
  26.         <App />
  27.     </ApolloProvider>
  28.     , document.getElementById('root'));
  29.      
  30. .then(res => {
  31. if (res === 200) {
  32.     localStorage.setItem("session", JSON.stringify(res.data));
  33.     history.push("/dashboard");
  34. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top