forked from aws-samples/aws-serverless-workshops
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtickets-get.js
32 lines (24 loc) · 827 Bytes
/
tickets-get.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const AWS = require("aws-sdk");
const table = process.env.TABLE_NAME;
exports.handler = (event, context, callback) => {
const docClient = new AWS.DynamoDB.DocumentClient();
const params = {
TableName: table
};
docClient.scan(params, function (err, data) {
if (err)
console.log(JSON.stringify(err, null, 2));
else {
let response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin" : "*", // Required for CORS support to work
"Access-Control-Allow-Credentials" : true // Required for cookies, authorization headers with HTTPS
},
body: JSON.stringify(data)
};
callback(null, response);
}
});
};