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

226
Views
¿Por qué recibí este tipo de error, no un constructor para javascipt?

Estoy tratando de crear un nuevo producto. Para probar si el resultado se envía a mi mongodb, ingreso los valores en cartero. Sin embargo, estoy confundido acerca de este error.

Este es mi archivo de producto

 const mongoose = require("mongoose"); const ProductSchema = new mongoose.Schema( { title: {type:String , required:true , unique:true}, description: {type:String , required:true}, img: {type:String , required:true }, categories: {type: Array , required:true }, size: {type:Array}, color: {type:Array}, price: {type: Number , required:true }, inStock:{type:Boolean , default:true}, }, { timestamps: true } ); module.export = mongoose.model("Product" , ProductSchema);

este es mi codigo postal

 const router = require("express").Router(); const Product = require("../model/Product") //Create new product(testing in postman) router.post("/", async (req,res)=>{ const newProduct = new Product(req.body); try{ const savedProduct = await newProduct.save(); res.status(200).json(savedProduct); }catch(error){ res.status(500).json(error) } })

Después de enviar los valores al cartero, siempre encuentro este error.

 TypeError: Product is not a constructor
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Tu estas usando

 module.export = mongoose.model("Product" , ProductSchema);

debería ser

 module.exports = mongoose.model("Product" , ProductSchema);
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!