Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!