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

122
Visualizações
Node not sending object properties to mongo db

I have a program that accepts an image and creates a string that links to the image to save in the database. currently I have the string stored in a state called image1 And I am sending the data to my backend with the following code on the front end

const scheduleEvent = (e) => {
  e.preventDefault();
  let userData = [
    {
      image: image1
    },
  ];
  axios.post(
    "proper-url",
    userData
    
  );
  console.log(userData) // this returns: 0: {image: "https://i.imgur.com/LnZUdnr.jpg"}
};

And I this is my webhook to capture the data and send it to the database

exports = async function(payload, response) {
  if (payload.body) {
      const body =  EJSON.parse(payload.body.text());
      const customerEvents= context.services.get("mongodb-atlas").db("db").collection("events");
      const event = {
           
    image: body.image1,
    
          
      };
  
      return await customerEvents.insertOne(event);
  }
  return  {}
};

However my database entries look like this _id:6229194de167780bd1982029 without the image variable. I know that my code is connecting to the database and adding things to it, but no matter what I do I cannot get it to record the image1 string

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In your client code you're sending a field named image, but in your server side you're looking for the field image1. This is undefined, which is why it's not showing up in your database.

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