From 0f1b9240bbd05b377e868faf78b89b509a3d7537 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Fri, 27 Oct 2017 13:24:41 -0400 Subject: ayeee --- graphcool/src/getPrice.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 graphcool/src/getPrice.js (limited to 'graphcool/src/getPrice.js') diff --git a/graphcool/src/getPrice.js b/graphcool/src/getPrice.js new file mode 100644 index 0000000..7808a85 --- /dev/null +++ b/graphcool/src/getPrice.js @@ -0,0 +1,26 @@ +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 }), + }) +} + + +module.exports = function(event) { + getItem().then(x => x.json()).then(res => { + console.log(res.data.Item.price); + }).catch(console.log) +} -- cgit v1.3