Created
September 27, 2019 18:21
-
-
Save joshuaaguilar20/9cfd36c60c10f8057dc20f9eee2c926a to your computer and use it in GitHub Desktop.
API returning different Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "sku_FI4lrgGXvza0nv", | |
"object": "sku", | |
"active": true, | |
"attributes": { | |
"name": "LC-81" | |
}, | |
"created": 1561053825, | |
"currency": "usd", | |
"image": "https://files.stripe.com/links/fl_live_WSngUWJBUIaD4RyvoKBsv9gL", | |
"inventory": { | |
"quantity": null, | |
"type": "infinite", | |
"value": null | |
}, | |
"livemode": true, | |
"metadata": {}, | |
"package_dimensions": null, | |
"price": 3800, | |
"product": "prod_FI4lzS3CCa2SiJ", | |
"updated": 1562867787 | |
}, |
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
//Fetching first Products
module.exports.handler = (event, context, callback) => {
const productPrice = {};
return stripe.products.list({ limit: 100 }).then((order) => {
return stripe.skus.list({ limit: 100 }).then((price) => {
const response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
},
body: JSON.stringify({
order: order.data,
price: price.data
}),
};
callback(null, response);
})
})
.catch((err) => { // Error response
console.log(err);
const response = {
statusCode: 500,
headers: {
'Access-Control-Allow-Origin': '*',
},
body: JSON.stringify({
error: err.message,
}),
};
callback(null, response);
})
};
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//Post Request To Fetch Next Set of 100 Products AWS Lambda
module.exports.handler = (event, context, callback) => {
const requestBody = JSON.parse(event.body);
const startingAfterID = requestBody.startingAfterId;
const startingAfterSku = requestBody.startingAfterSku;
return stripe.products.list({
limit: 100,
starting_after: startingAfterID
}).then((order) => {
};