Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjonathanmessing
5,443 PointsCouldn't these call backs be done in promises?
I am getting an error saying these callbacks should be done with the promise library?
2 Answers
Cezary Burzykowski
18,291 PointsYes, because they should.
You can still use callback functions and the code will work, but most of the Mongoose methods return promises (remove(), save(), find(), findOne(), etc.) and the best way to deal with promises is with .then().
For example:
animal.save().then( here goes function that does something with the result)
Ivan Kuznetsov
Courses Plus Student 733 PointsCezary Burzykowski great! Thanks for the tip.