Skip to content

Instantly share code, notes, and snippets.

@siddhant1
Created March 20, 2019 09:53
Show Gist options
  • Save siddhant1/62a07c610783bc90ebf9158491e2b051 to your computer and use it in GitHub Desktop.
Save siddhant1/62a07c610783bc90ebf9158491e2b051 to your computer and use it in GitHub Desktop.
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