diff options
Diffstat (limited to 'functions/getPrice.js')
| -rw-r--r-- | functions/getPrice.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/functions/getPrice.js b/functions/getPrice.js new file mode 100644 index 0000000..61c29e6 --- /dev/null +++ b/functions/getPrice.js @@ -0,0 +1,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) + |
