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

1.2K
Views
mongoose findbyId() showing 'The "path" argument must be of type string. Received an instance of model'

so this is my code here (express)

    app.get('/:id', async (req,res) => {
        const id = req.params.id;
        console.log(id)
        const bids = await Bid.findById(id)
        res.render(bids)
    
    })

so this is what I got in the console

61671cef1c1db40b750502b0
(node:8068) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of model
    at validateString (internal/validators.js:124:11)
    at extname (path.js:828:5)
    at new View (D:\konectapp-1\node_modules\express\lib\view.js:56:14)
    at Function.render (D:\konectapp-1\node_modules\express\lib\application.js:570:12)
    at ServerResponse.render (D:\konectapp-1\node_modules\express\lib\response.js:1012:7)
    at D:\konectapp-1\app.js:62:9
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8068) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8068) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I can see it is providing the object id at the top of the console as I have logged, but when I passed it to the findbyid , it is giving me this error

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

...but when I passed it to the findbyid , it is giving me this error

There seems to be nothing wrong with the mongoose findById(), although it's better to handle the errors properly when using async/await with a try/catch block.

[ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string...

This throws from res.render(bids).

res.render() only accepts a string which is the file path of the view file to render. But here you're passing an object as the parameter. See the documentation.

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!