lundi 12 décembre 2016

Right way to make AJAX GET and POST calls in EmberJS

I've started working on EmberJS and I absolutely love it. It does have a learning curve but I believe it has fundamentally very meaningful principles.

My questions is how to make GET and POST calls in Ember JS. I understand that there are models / store, but models (in my opinion) would be to only a particular entity's attributes.

Any thoughts on the following questions would be great.

1. USER A send friend request to USER B. Should there be a "Request"
   model? And do I just make a POST request?

2. Some arbitrary data needs to be returned for the page. Not
   particularly of a model. Should I still make a model for that?
   For use a simple GET request?

3. User needs to update this profile photo. How can the file
   to be uploaded, be set as a model attribute?

How should I go about making regular GET and POST calls (if I am to do them at all). Just use jQuery's $.ajax() or is there another way. I also found a service ember-ajax which has extended the $.ajax into a promises style.

Any thoughts would be much appreciated.

Long live EmberJS :)




Aucun commentaire:

Enregistrer un commentaire