Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda