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

102
Views
ypeError: exportaciones.getAllProducts no es una función

Creé un archivo productcontroler.js donde coloqué la función que se ejecuta en las llamadas de rutas

 exports.getAllProducts() = (req,res)=>{ res.status(200).json({message:"Route is working fine"}); }

y aquí está la ruta

 const express = require("express"); const {getAllProducts} = require("../controller/productController.js") const router = express.Router(); router.route("/product").get(getAllProducts);

y estoy recibiendo este error

 exports.getAllProducts() = (req,res)=>{ ^ TypeError: exports.getAllProducts is not a function

después de eliminar los paréntesis de getAllproduct en el archivo del controlador

 hrow new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn)) ^ TypeError: Router.use() requires a middleware function but got a Object at Function.use (C:\Users\saran\OneDrive\Desktop\Learn React\mern\node_modules\express\lib\router\index.js:464:13) at Function.<anonymous> (C:\Users\saran\OneDrive\Desktop\Learn React\mern\node_modules\express\lib\application.js:220:21) at Array.forEach (<anonymous>) at Function.use (C:\Users\saran\OneDrive\Desktop\Learn React\mern\node_modules\express\lib\application.js:217:7) at Object.<anonymous> (C:\Users\saran\OneDrive\Desktop\Learn React\mern\backend\app.js:13:5)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

es posible que se esté olvidando de exportar uno de sus archivos como su enrutador

si está utilizando const router = express.Router();

no olvides exportar module.exports=router;

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!