Skip to content

Instantly share code, notes, and snippets.

@saifalfalah
Last active April 29, 2020 02:47
Show Gist options
  • Save saifalfalah/b80c3fa5598866e9912830a9d2c7d5c7 to your computer and use it in GitHub Desktop.
Save saifalfalah/b80c3fa5598866e9912830a9d2c7d5c7 to your computer and use it in GitHub Desktop.
begin data test
let arc = require("@architect/functions");
let parseBody = arc.http.helpers.bodyParser;
const data = require("@begin/data");
exports.handler = async function http(req) {
let body = parseBody(req);
let cart = body.cart;
// cart is of the form: { cc1: 1, cc2: 2, cc3: 3, cc4: 4, cc5: 5 }
let table = "orders";
let key = orderID;
let orderData = body.cart;
await data.set({ table, key, orderData });
return {
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST",
},
body: JSON.stringify({ data: "success" }),
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment