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

119
Visualizações
React to Lambda to DynamoDB ("key" prop issue)

I have this code to send the request from React app using Axios to Lambda:

export const addTodo = createAsyncThunk(
  'todoApp/todos/addTodo',
  async (todo, { dispatch, getState }) => {
    
    const response = await axios.post('https://api.us-west-2.amazonaws.com/prod/', { 
      Key: {
        key1: `${todo.id}`,
        key2: `${todo.title}`,
        key3: `${todo.notes}`,
        key4: `${todo.startDate}`,
        key5: `${todo.dueDate}`,
        key6: `${todo.completed}`,
        key7: `${todo.starred}`,
        key8: `${todo.important}`,
        key9: `${todo.deleted}`,
        key10: `${todo.labels}`
        }
     });
    const data = await response.data;

    dispatch(getTodos());

    return data;
  }
);

And here is the Lambda function:

const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient({region: "us-west-2"});

exports.handler = (event, context, callback) => {
    console.log("Processing...");
    const params = {
        Item: {
            "id":  event.key1,
            "title": event.key2,
            "notes": event.key3,
            "startDate": event.key4,
            "dueDate": event.key5,
            "completed": event.key6,
            "starred": event.key7,
            "important": event.key8,
            "deleted": event.key9,
            "labels": event.key10
        },
        TableName: "Todo"
    };
    const response = {
    statusCode: 200,
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Credentials': true,
    },
    body: JSON.stringify('Done'),
  };
    
    docClient.put(params, function(err, data) {
        if(err){
            callback(err, null);
        } else {
            callback(null, data);
        }
    })
};

The exact same code is working on my other app for Contacts but not in here which is a Todo app. I always get the error for:

Warning: Each child in a list should have a unique "key" prop.

The issue is that Lambda function is not getting the key items that I configured. Is there anything I missed?

about 4 years ago · Juan Pablo Isaza
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