Product validation failed: imgUrl: imgUrl is required. getting this error tried with multiple ways still not able to solve it

Viewed 10
const mongoose = require('mongoose')

const ProductsSchema = mongoose.Schema({
    title: {
        type: String,
        required: [true, "title is required"],
        trim: true
    },
    desc: {
        type: String,
        required: [true, "desc is required"],
        trim: true
    },
    price: {
        type: String,
        required: [true, "price is required"],
        trim: true
    },
    userId:{
        type: String,
        required: true
    },
    imgUrl: {
        type: String,
        required: [true, "imgUrl is required"],
        trim: true
    }
}, {timestamps : true})

const allProducts = mongoose.model('Product', ProductsSchema)

module.exports = allProducts
0 Answers
Related