diff options
| author | Wes Bos <wesbos@gmail.com> | 2017-08-11 14:56:13 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2017-08-11 14:56:13 -0400 |
| commit | 416c2cbae0e69b724876d232bf813eefd7550174 (patch) | |
| tree | ce7109c0f61dbeee7077164cb48a4681214e0464 /functions/getPrice.js | |
| parent | 222ab374d53a206332b1ab51c7c43f6d5dc7a31e (diff) | |
getting there
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) + |
