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

463
Views
Empujando la matriz de objeto de reaccionar al problema del servidor mongodb + express

Estoy almacenando una matriz de objetos, pero me está dando el siguiente error.

(nodo: 87929) UnhandledPromiseRejectionWarning: ValidationError: la validación del lugar falló: placesToVisit: la conversión a incrustado falló para el valor "[{"name":"xczc","ubicación":"zczxc","description":"czxczx"}]" (escriba cadena) en la ruta "placesToVisit" debido a "ObjectParameterError"

aquí está mi esquema:

 placesToVisit: [ { name: { type: String, required: [true, "Please enter the place's name"], }, description:{ type: String, required: [true, "Please enter the place's description"], }, location:{ type: String, required: [true, "Please enter the place's location"], } }, ],

aquí está mi controlador:

 exports.createPlace = async (req, res) => { try { const newPlace = await new Place({ placesToVisit:req.body.placesToVisit, }); newPlace.save() debugger res.status(201).json({ success:true, message:"Place Created Successfully", newPlace }) } catch (error) { return res.status(500).json({ success:false, error:error.message }) } };

aquí está mi estructura formdata:

 data.append("placesToVisit",JSON.stringify(values.placesToVisit))

aquí está ss de yaload ingrese la descripción de la imagen aquí

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Debe convertir la cadena en una matriz:

 placesToVisit: JSON.parse(req.body.placesToVisit),
over 4 years ago · Santiago Trujillo 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!