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 trialMicah Dunson
34,368 PointsVote not defined
In following along with the video, everything has worked fine expect when I try to vote. When I add the "/vote-up" or "/vote-down" to the end of my api call I get this error: { "error": { "message": "vote is not defined" } }
with a 500 err on the server. I have not been able to find the error that I'm making. I appreciate any help.
2 Answers
Aleks Dahlberg
19,103 PointsHey Micah,
You didn't post any code so I tried to replicate the problem (I'd just finished the series) and believe I may have found where you a simple naming error.
in the models.js file, two instance methods were created:
AnswerSchema.method('update', function(updates, callback){
..........
});
AnswerSchema.method('vote', function(vote, callback){
............
});
I think you may have miss spelt 'vote' either in the naming of the instance method or in the function method parameter before the callback.
//update instance method
AnswerSchema.method('update', function(updates, callback)
//vote instance method
AnswerSchema.method('vote', function(vote, callback)
Micah Dunson
34,368 PointsThanks a ton! You were right Aleks as far as where the issue was. I hadn't updated the "vote" parameter in the cb function of the vote instance method. I made the change and everything works fine as it's supposed to.
Aleks Dahlberg
19,103 PointsNo problem!
Thomas Nilsen
14,957 PointsThomas Nilsen
14,957 PointsIt's difficult to say what to problem is without seeing some code.