Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

data.js

23 lines501 Bytes

1import fetch from 'isomorphic-unfetch'
2​
3const projects = [
4 'facebook/flipper', 'vuejs/vuepress', 'rust-lang/rust', 'zeit/next.js'
5]
6​
7export default (req, res) => {
8 if (req.query.id) {
9 // a slow endpoint for getting repo data
10 fetch(`https://api.github.com/repos/${req.query.id}`)
11 .then(resp => resp.json())
12 .then(data => {
13 setTimeout(() => {
14 res.json(data)
15 }, 2000)
16 })
18 return
19 }
20 setTimeout(() => {
21 res.json(projects)
22 }, 2000)