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

285
Views
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 answers
Answer question

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 Report

0

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

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!