diff options
| author | Wes Bos <wesbos@gmail.com> | 2017-08-25 09:33:53 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2017-08-25 09:33:53 -0400 |
| commit | 7af74ff8988961c988f03c95961b70c2918521ae (patch) | |
| tree | d73cd0dd94751b76595b7febcae4162811c2040b /functions/createCharge.js | |
| parent | 416c2cbae0e69b724876d232bf813eefd7550174 (diff) | |
yay
Diffstat (limited to 'functions/createCharge.js')
| -rw-r--r-- | functions/createCharge.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/functions/createCharge.js b/functions/createCharge.js index ecd22a1..215f8de 100644 --- a/functions/createCharge.js +++ b/functions/createCharge.js @@ -3,15 +3,15 @@ const graphCoolEndpoint = 'https://api.graph.cool/simple/v1/cj5xz8szs28930145gct require('isomorphic-fetch') -const query = ` -query SingleItem { - Item(id: "cj64bs7vuuqgu0116ul5cm223") { - price - } -} -`; +const getPrice = (itemId) => { + const query = ` + query SingleItem { + Item(id: "${itemId}") { + price + } + } + `; -const getPrice = (id) => { return fetch('https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj', { method: 'post', headers: { @@ -33,7 +33,7 @@ const createStripeCharge = (token, amount) => { module.exports = function(event) { return new Promise((resolve, reject) => { // first find out the price of the item - getPrice() + getPrice(event.data.itemId) .then(res => res.json()) .then(res => { console.log(`Back with the price ${res.data.Item.price}!`); @@ -43,7 +43,6 @@ module.exports = function(event) { console.log(`Back! charge ${res.id} for the amount ${res.amount}`); event.data.charge = res.id; event.data.amount = res.amount; - console.log(event.data); resolve(event); }) .catch(err => { |
