Search code examples
ember.jsember-cliember-cli-mirage

Ember-Cli-Mirage 404


Just followed the documentation but every time I navigate or call to the url, it returns 404 for me

// app/mirage/config.js
export default function() {

  this.get('/api/users', function() {
    return {
      users: [
        {id: 1, name: 'Zelda'},
        {id: 2, name: 'Link'},
        {id: 3, name: 'Epona'},
      ]
    }
  });

}

Uncaught UnrecognizedURLError: /api/users

Thanks for your help.


Solution

  • Navigating directly to that URL in your browser will not follow the mirage pipeline. Rather, when your ember application would have queried the end points you have configured, mirage will send mocked data instead. Therefore you need to implement something that will call your endpoint from within your Ember app.