Context: I'm working on a blog post and tutorial that I wish existed. It's challenging because this is the first non-trivial Ember app I've made.
I've got an API that has these endpoints:
/cars GET /search_cars POST
The endpoint /search_cars needs to go an external list of cars so that the user can later add the car that is found to a list of favorites. Using /cars?name=... I don't think is appropriate here because that would be representing a resource that is local to my app, but it's not.
I have a kind of ephemeral resource. Should I create an explicit controller for this? I think reusing the car model would work but in a different context? I think it would work like this:
- The /cars
route/action/resourceis normal ember-data setup (this is already working). - Create a route and controller for the one-off
/search_carsfeature. In the controller, go to the external data source, fetch the cars that match and construct an array of car models. Return that back to the user. The user adds the car to their list of favorites which is what the/carsresource is.
I don't know if this is idiomatic. I'll try whipping up a fiddle but it's difficult for me to do so (I could do so if I was better with faking data with fixtures).
Aucun commentaire:
Enregistrer un commentaire