showing results for - "how to use fetch in gatsby"
Aaron
17 Jan 2018
1  const [starsCount, setStarsCount] = useState(0)
2  useEffect(() => {
3    // get data from GitHub api
4    fetch(`https://api.github.com/repos/gatsbyjs/gatsby`)
5      .then(response => response.json()) // parse JSON from request
6      .then(resultData => {
7        setStarsCount(resultData.stargazers_count)
8      }) // set data for the number of stars
9  }, [])