mercredi 22 mai 2019

Ember Mirage - Not able to capture the response

A newbie to ember, I am trying to simulate the API server using ember-cli-mirage. I am creating a request from account.js through store but the response is not something I expect.

## /app/routes/account.js

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default Route.extend({
  store: service(),

  model() {
    this.store.findAll('accounts').then(response => {
      console.log(response)
    });
    // return this.store.findAll('accounts');
  }
});



## /app/mirage/config.js

export default function () {
  this.get('/accounts', (schema) => {
    return {
      data: [
        {
          firstName: 'John'
        }
      ]
    };
  }, {timing: 2000});
}

This is the response I get, enter image description here

Is there anything missing?




Aucun commentaire:

Enregistrer un commentaire