Created
March 20, 2019 09:53
-
-
Save siddhant1/62a07c610783bc90ebf9158491e2b051 to your computer and use it in GitHub Desktop.
This file contains 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 React, { Component } from "react"; | |
import ApolloClient from "apollo-boost"; | |
import { ApolloProvider } from "react-apollo"; | |
import GetTodos from "./GetTodos"; | |
export var client; | |
class Home extends Component { | |
constructor(props) { | |
super(props); | |
const ACCESS_TOKEN = localStorage.getItem("access_token"); | |
client = new ApolloClient({ | |
uri: `https://todo-hasura-app.herokuapp.com/v1alpha1/graphql`, | |
headers: { | |
Authorization: `Bearer ${ACCESS_TOKEN}` | |
} | |
}); | |
} | |
login() { | |
this.props.auth.login(); | |
} | |
render() { | |
const { isAuthenticated } = this.props.auth; | |
return ( | |
<div className="container"> | |
{isAuthenticated() && ( | |
<ApolloProvider client={client}> | |
<GetTodos /> | |
</ApolloProvider> | |
)} | |
</div> | |
); | |
} | |
} | |
export default Home; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment