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

284
Vistas
Type Error: findByID is not a function (Node.js)

I have two separate Folders.

/controller/anbieter.js

function getAnbieterById(req, res) {
        var userid = parseInt(req.params.id);
        let anbieter = Anbieter.findById(userid);
        res.send(anbieter);
    }; 

/model/anbieter.js

findById(id){
        let sql = `SELECT * FROM Anbieter WHERE Anbieter_id= ${id};`;
    
        db.query(sql);
    }

I am getting error that Anbieter.findById is not a function

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

0

The way you are calling Anbieter.findById(userid); is supposed to be defined as a static method. so instead of findById use

 class Anbieter{
  static findById(){
   // your logic goes here
  }
}

And, I think you would like to use async with your functions since db queries are asynchronous.

about 4 years ago · Juan Pablo Isaza Denunciar

0

export function findById and import in this function /controller/anbieter.js .

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