From 416c2cbae0e69b724876d232bf813eefd7550174 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Fri, 11 Aug 2017 14:56:13 -0400 Subject: getting there --- functions/getPrice.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 functions/getPrice.js (limited to 'functions/getPrice.js') 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) + -- cgit v1.3