summaryrefslogtreecommitdiffstats
path: root/functions/getPrice.js
blob: 61c29e6fe369a343734cfe3a863c892586ca5875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require('isomorphic-fetch')

const query = `
query SingleItem {
  Item(id: "cj64bs7vuuqgu0116ul5cm223") {
    price
  }
}
`;

function getItem(id) {
    return fetch('https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj', {
      method: 'post',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ query }),
    })
}

getItem().then(x => x.json()).then(res => {
  console.log(res.data.Item.price);
}).catch(console.log)