Hi, devs!
Every day we need to solve the errors and bugs and usually they appears just all the time.
Let's observe examples of error messages in this context:
Error: Route.get() requires a callback function but got a [object Object]
Error: Route.POST() requires callback functions but got a [object Undefined]
What you need to do to solve?
First thing: debug your code!
If you are using VSCode, use the debug tool at the left (a play button with a bug on it)
If the message is coming with something undefined or object you need to looking for root cause.
List of verifications to this error:
1 - You use the exports to permit other file to use you function?
2 - That function you call exists on its file?
3 - When you use module.exports take care to use correctly, remember if you use with module.exports = { functionExported }
you need to use with a require in other file like const example = require('./example')
and do example.functionExported
to use.
4 - When you use routes and controllers to make yours endpoints, take care to exports the necessaries functions.
Do you have more tips and tricks to solve this error? Post on comments.
Contacts
Email: luizcalaca@gmail.com
Instagram: https://www.instagram.com/luizcalaca
Linkedin: https://www.linkedin.com/in/luizcalaca/
Twitter: https://twitter.com/luizcalaca
Top comments (2)
Thank you for this blog. It helps me a lot!
thank you so much