summaryrefslogtreecommitdiffstats
path: root/functions/getPrice.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2017-08-11 14:56:13 -0400
committerWes Bos <wesbos@gmail.com>2017-08-11 14:56:13 -0400
commit416c2cbae0e69b724876d232bf813eefd7550174 (patch)
treece7109c0f61dbeee7077164cb48a4681214e0464 /functions/getPrice.js
parent222ab374d53a206332b1ab51c7c43f6d5dc7a31e (diff)
getting there
Diffstat (limited to 'functions/getPrice.js')
-rw-r--r--functions/getPrice.js24
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)
+