Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
Axios delete method with Lambda

I have the following code to delete a contact from my contactApp, which is using axios in React to send the request:

export const removeContact = createAsyncThunk(
  'contactsApp/contacts/removeContact',
  async (contactId, { dispatch, getState }) => {
    await axios.delete('https://api.com/prod', { 
      key1: `${contactId}`
     });
    console.log(">>>>>>>" + contactId)
    return contactId;
  }
);

and this is the Lambda function to delete the item from the DynamoDB table:

var params = {
  TableName : 'Contacts',
  Key: {
    id: event.key1
  },
};

var documentClient = new AWS.DynamoDB.DocumentClient({region: "us-west-2"});

documentClient.delete(params, function(err, data) {
  if (err) console.log(err);
  else console.log(data);
});

The problem is, the item won't remove from the table, and the reason is that Lambda not receiving the "contactId" from ReactApp, which is containing which id should be deleted. Because when I test the code from Lambda like the following, it works:

  Key: {
    id: "123" //Actual ID in table
  },

So I think the issue is this in react:

key1: `${contactId}`

What am I missing?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

DELETE requests do not have body.

use

await axios.delete('https://api.com/prod', { 
  data: {key1: `${contactId}`}
 });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!