Closed cmpsoares91 closed 10 years ago
Couple things -
1) You API route isn't returning anything:
http://beta.quantbull.com/workspace/friends/list
returns an empty array:
and http://beta.quantbull.com/friends/list
returns a 404
app.get('/friends/list', passportConf.isAuthenticated, function (req, res) {
var temp = [];
for (var i = 0; i < req.user.friends.length; i++) {
if (req.user.friends[i].verified) {
console.log(req.user.friends[i].email);
temp.push(req.user.friends[i].email);
}
}
// This will return your JSON output when it's working properly!
// Test this well...
User.find({ email: { $in : temp } }, function(err, users) {
res.json(users);
});
});
Get this working properly first - then work on consuming the JSON in your page.
It doesn't give anything because you hadn't any friend connections, I've added manually a friend connection, so if you check again it should work.
Are you getting the same result as me?
_Update:_ I found the source of the problem but can't figure out why it works in accounts.jade but not in friends.jade:
// Load moment.js
$.getScript('lib/moment/min/moment.min.js')
.done(function(script, textStatus) {
alert('getScripts are done...');
// Now populate the user table
populateTable();
});
Both getScripts()'s look exactly the same but somehow in accounts.jade it looks for localhost:8080/lib/moment/min/moment.min.js
and in friends.jade it looks for localhost:8080/friends/lib/moment/min/moment.min.js
.
Any idea why?
Well, I hacked it and changed the link from 'lib/moment/min/moment.min.js' to '../lib/moment/min/moment.min.js' and it works... I think I'm getting the hang of it...
Glad you found it! You are seeing some strange stuff... ;(
Hehe! How do you mean?
Hey Dan,
Somehow I'm unable to populate the accounts table in a friends list.
I'm using the following functions:
And the script from the controller:
Output if I got to the link in the browser:
And I get
[ ]
when I enter console.log()userListData); in the chrome dev tools console. I don't understand why. Any ideas? I'm not very familiar with web design debugging...P.S. It's hosted at beta.quantbull.com if you want to live test it?