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

115
Vistas
I am stuck at "The Shipped item's tracking number is required"

I have a model

const FormDataSchema = new mongoose.Schema({...})

// the Shipping schema
const ShippingSchema = new mongoose.Schema({
    itemstrackno : {
        type: String,
        minlength: [3, "Minimum characters for this field is 3"],
        maxlength: [100, "Maximum characters for this field is 100"],
        required: [true, "The Shipped item's tracking number is required"],
        trim: true,
        unique: true
    },
    formData: [FormDataSchema]
}, {timestamps: true})

const Shipping = mongoose.model("Shipping", ShippingSchema)
module.exports = Shipping

my post controller

// post a shipment
exports.postShipment = async (req, res, next) => {
const {itemstrackno, formdata} = req.body

try {
    const trackedItem = await Shipping.findOne({itemstrackno})
    
    if(trackedItem){
        return next(new ErrorResponse("An Item with this track number exists", 400))
    }
    
    const shipment = await Shipping.create({itemstrackno, formdata})
    
    res.status(200).json({
        success: true,
        data: shipment
    })
} catch (error) {
    next(error)
}

}

when i send a post request with postman i get "The Shipped item's tracking number is required" Error. What am i doing wrong?

THE POSTMAN IMAGE

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Seems like you have a typo in the request. You have marked itemstrackno as required but you are sending itemtrackno

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