Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Delete data

DELETE data

const apiName = 'MyApiName'; // replace this with your api name.
const path = '/path'; //replace this with the path you have configured on your API
const myInit = {
headers: {} // OPTIONAL
};
API.del(apiName, path, myInit)
.then((response) => {
// Add your code here
})
.catch((error) => {
console.log(error.response);
});

Example with async/await

async function deleteData() {
const apiName = 'MyApiName';
const path = '/path';
const myInit = {
headers: {} // OPTIONAL
};
return await API.del(apiName, path, myInit);
}
deleteData();

Access body in the Lambda function

// using a basic lambda handler
exports.handler = (event, context) => {
console.log('body: ', event.body);
};
// using serverless express
app.delete('/myendpoint', function (req, res) {
console.log('body: ', req.body);
});