Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda