lundi 5 décembre 2016

EmberJS getting user profile information

In my Rails API I am using JSONAPI structure which Ember expects by default.

I have a Rails route http://localhost:3000/profile which will return the currently logged in user JSON.

How do I make an arbitary request to this /profile endpoint in Emberjs so I can get my logged in user's JSON in my router's model() hook?

I tried following this guide here:

http://ift.tt/2gGaULj

And have this code:

return this.get('store').query('user', {
  filter: {
    email: 'jim@gmail.com'
  }
}).then(function(users) {
  return users.get("firstObject");
});

It is returning the incorrect user however. It also seems like it doesn't matter what the value of 'email' is, I can pass it 'mud' and it will return all users in my database.

Is there no way for me to make a simple GET request to /profile in my model() hook of my profile route in Ember?




Aucun commentaire:

Enregistrer un commentaire