Delete data
DELETE data
1const apiName = 'MyApiName'; // replace this with your api name.2const path = '/path'; //replace this with the path you have configured on your API3const myInit = {4 headers: {} // OPTIONAL5};6
7API.del(apiName, path, myInit)8 .then((response) => {9 // Add your code here10 })11 .catch((error) => {12 console.log(error.response);13 });
Example with async/await
1async function deleteData() {2 const apiName = 'MyApiName';3 const path = '/path';4 const myInit = {5 headers: {} // OPTIONAL6 };7 return await API.del(apiName, path, myInit);8}9
10deleteData();
Access body in the Lambda function
1// using a basic lambda handler2exports.handler = (event, context) => {3 console.log('body: ', event.body);4};5
6// using serverless express7app.delete('/myendpoint', function (req, res) {8 console.log('body: ', req.body);9});