mercredi 8 novembre 2017

Ember.JS - Submit button runs a query and returns JSON object to template. Do I run the query in a service, as a model or in a route?

I am still a novice and I am converting an application from Node Express to Ember I'm confused on some of the methodology involved in Ember.

In the current application there is a form that is submitted and then executes a query based on the input. In the app.js of the current application there is a switch statement on POST:

app.post('/test', function(req, res){
switch(req.body.module) {
    case "Option 1":
  getOption1Results(req, res);
    break;
    case "Option2":
  getOption2Results(req, res)
  break;
    case "Option 3":
  getOptio3Results(req, res)
  break;
  case "Option 4":
  getOption4Results(req, res)
  break;
  default:
    console.log("didn't work")

}

To get the same results in Ember I don't know whether I should be creating a service to do the above or creating a route and executing the query in a model that's passed to the template.

Any advice is very much appreciated.




Aucun commentaire:

Enregistrer un commentaire