mercredi 19 octobre 2016

Ember customer host adapter not overiding mirage host

I'm using Ember-cli-mirage to mock data. I want to slowly integrate parts of the production api which is located on my local machine at http://localhost:8000. Ember docs tell me that I should be able to set an adapter so I can have a different host for each model.

I have a customer model, and have setup ember-cli-mirage which is successfully serving data. The customer model is the first model I want to split out to localhost:8000.

I've setup adapters/customer.js with the following:

import DS from 'ember-data';

export default DS.RESTAdapter.extend( {
  host: 'http://localhost:8000',
  namespace: 'api/v1'
});

But when I make the call I'm getting an error:

Mirage: Error: Your Ember app tried to GET 'http://localhost:8000/api/v1/customers',
         but there was no route defined to handle this request.
         Define a route that matches this path in your
         mirage/config.js file. Did you forget to add your namespace?

And my header inspector shows that customers is making the request to the mirage server:

Request URL:http://localhost:6543/customers
Request Method:GET
Status Code:304 Not Modified
Remote Address:[::1]:6543

I suspect it's something to do with my config/environment.js setup so I'm looking at a variation of http://ift.tt/2emZuJJ as a potential workaround. But I can't see why mirage won't accept the adapter overide.




Aucun commentaire:

Enregistrer un commentaire