Stormpath-Calling Specific Data

I'm building a web application which uses a favourites feature. The web-app is built using node & express.js and uses the Stormpath api for user management. To make this feature, i need to access certain custom data(which will be updated). To do this I need to access a users account information from Stormpath when they are logged on to my site but I'm new to node and can't see a way to do this.

Help??

It sounds to me as if you already have a user account, and want to grab the custom data to store stuff in it -- is that correct?

If so, here's how you can do this:

app.get('/test', function(req, res) {
  var account = ...;  // I'm assuming you already have an account.
  account.getCustomData(function(err, data) {
    if (err) res.send(500).end()
    res.json(data);
  });
});

The above route will return the user's custom data as JSON.

Below is an example where I'll store some stuff in custom data, then persist it to Stormpath:

app.get('/test', function(req, res) {
  var account = ...;  // I'm assuming you already have an account.
  account.getCustomData(function(err, data) {
    if (err) res.send(500).end()
    data.favorites = ['cookies', 'and', 'cream'];
    data.pet = {
      type: 'dog',
      name: 'Scribbles',
      breed: 'chihuahua',
      color: 'brindle'
    };
    data.save(function(done) {
      res.json({ message: 'Finished saving data to Stormpath!' });
    });
  });
});