mardi 4 avril 2017

EmberJS not passing my dynamic route segment to the api

I have an API (I am writing in ASP.Net Web API) that has an end point which returns all of the counties in a state.

My route should look like this: http://localhost:4200/counties/CA or http://localhost:4200/counties/NY

My API is working fine.

However, I am getting: Error while processing route: counties Ember Data Request GET http://localhost:50523/api/counties returned a 404

My router mapping is:

Router.map(function() {
  this.route('states');
  this.route('counties', {path : 'counties/:state'});
});

I also tried 'counties/:fips' - fips is the primaryKey designated in the serializer. And 'counties/:county_id' and 'counties/:state_id' for the hell of it.

routes/counties.js is:

export default Ember.Route.extend({
  model() {
    return this.get('store').findAll('county');
  }
});

My models/county.js:

export default DS.Model.extend({
  state: DS.attr('string'),
  countyName: DS.attr('string'),
  fips: DS.attr('string'),
});

Note that the states route and API is working just dandy.




Aucun commentaire:

Enregistrer un commentaire