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

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

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 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