-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmartpill-deletePill.js
More file actions
48 lines (40 loc) · 1.19 KB
/
smartpill-deletePill.js
File metadata and controls
48 lines (40 loc) · 1.19 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict'
var aws= require('aws-sdk');
const documentClient = new aws.DynamoDB.DocumentClient({region: 'eu-west-1'});
exports.handler = async (event, context, callback) => {
//const pillId = 'bce7690a-0981-43ec-9757-9601c565b581';
const pillId = event.pathParameters.id;
console.log('pillId:' + pillId);
console.log(context);
console.log(event)
//console.log('Event: \n'+JSON.stringify(event))
await deletePill(pillId).then(() => {
callback(null, {
statusCode: 200,
body: JSON.stringify(event),
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
}
})
}).catch((err) => {
console.error(err)
callback({
statusCode: 400,
body: err,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
}
}, null)
});
};
function deletePill(pillId) {
var params = {
TableName: 'smartpill-pills',
Key: {
id: pillId
}
};
return documentClient.delete(params).promise();
}