Hi I'm quite new with Parse and Node.js.
When I'm trying to define a function:
app.get('/something', function(req, res) {
var query = new Parse.Query("Something");
query.find({
success: function(objects) {
res.render('something-else', {
somethings: objects
});
}
});
});
I'm met with a Result: success/error was not called
Subsequently when I try to add in the error either by adding res.error or status.error, I get these respective errors:
app.get('/something', function(req, res) {
var query = new Parse.Query("Something");
query.find({
success: function(objects) {
res.render('something-else', {
somethings: objects
});
},
error: function() {
res.error("error");
}
});
});
TypeError: Object [object Object] has no method 'error'
and for status:
app.get('/something', function(req, res) {
var query = new Parse.Query("Something");
query.find({
success: function(objects) {
res.render('something-else', {
somethings: objects
});
},
error: function() {
status.error("error");
}
});
});
ReferenceError: status is not defined
I understand that that probably means I need to create the status variable somewhere, but where would be a good place to do it and how?
Thanks so much!
express' response object does not have a function called "error":
http://expressjs.com/api.html#res.status
Try instead:
app.get('/something', function(req, res) {
var query = new Parse.Query("Something");
query.find({
success: function(objects) {
res.render('something-else', {
somethings: objects
});
},
error: function(err) {
res.send(500, err);
}
});
});