Last active
April 29, 2020 02:47
-
-
Save saifalfalah/b80c3fa5598866e9912830a9d2c7d5c7 to your computer and use it in GitHub Desktop.
begin data test
This file contains 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
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