I'm facing an issue while developing an application using backbone.js and express.js. The problem lies in returning values from express to backbone. Even a simple Curl request didn't work properly - I was able to display req.params on the server side, but couldn't retrieve it on the client side even after using JSON.stringify(). Strangely, when I tried the same code with a basic echo json_encode() in PHP, it worked like a charm...
Below is a snippet of a simple test on the server side:
var express = require("express");
var app = express();
app.get('/user/:id/:pass', function(req, res){
res.status(200);
res.send({"id": "1"});
});
However, on the client side, I don't seem to receive any success or error callback... Here's a part of the code:
var U1 = new User();
U1.fetch({
success: function(data) {
console.log('User fetched.');
},
error: function(model, error) {
console.log('user Error: '+error);
}
});
Could someone please point out what might be wrong with my approach towards express.js?
Thanks!