Ok so I am making a nodeJS application that uses Stormpath to manage user account information.
At the moment users can come to the web app and are asked to login/register. Once they do they are re-directed to home page.
Now I want to grab their data from stormpath and display it on-screen in their profile page. So their email, name, address and custom data is what I am after.
Now I DO NOT want to make this call subject to what "view" they are in rather when they click on the appropriate button.
this is how you do it with a VIEW --- Which is NOT what I am looking for.
var stormpath = require('express-stormpath');
app.get('/email', stormpath.loginRequired, function(req, res) {
res.send('Your email address is:', res.locals.user);
});
How do you perform this operation in a normal jQuery function?
Yo, it sounds like what you want to do is use jQuery to grab a user's account data and use it on the page. The only way to do this is to first pass the user's JSON data into the view.
jQuery is only going to look at the DOM, so it only has access to data which was already inside the view -- if you don't want the user data in the view, there's no way to grab this information with an AJAX type request.
What you could do is update your view code such that the HTML returned contains the user's data in JSON format in a hidden div, then use jQuery to extract that data from the hidden div and use it.
Does that make sense?