Last active
April 5, 2019 18:40
-
-
Save hiiamyes/c27a0986ad1047c0bfd4c8459f7d2879 to your computer and use it in GitHub Desktop.
data-visualization-2-graphql
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 React, { useState, useEffect } from "react"; | |
| import axios from "axios"; | |
| import { draw } from "./chart"; | |
| const App = () => { | |
| const [rainfalls, setRainfalls] = useState(null); | |
| useEffect(() => { | |
| async function get() { | |
| const { | |
| data: { | |
| data: { station } | |
| } | |
| } = await axios.request({ | |
| method: "POST", | |
| url: "http://localhost:4000", | |
| data: { | |
| query: ` | |
| query{ | |
| station(id: "466900") { | |
| id | |
| rainfalls { | |
| date | |
| value | |
| } | |
| } | |
| }` | |
| } | |
| }); | |
| const { rainfalls } = station; | |
| setRainfalls(rainfalls); | |
| draw({ rainfalls }); | |
| } | |
| if (!rainfalls) get(); | |
| }); | |
| return <div className="chart" />; | |
| }; | |
| export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment