ember mirage seed db dynamically

67 Views Asked by At

I know when application loads, mirage seeds the database. But I wanted to know is there a way to change the seeded database dynamically later on (for example on some user actions).

So, I have an API which gives me the status of the progress and I am polling that API call. Initially Mirage seeds the database for me but every time I make that API call, same data is returned and I want the data to change so that I can test my UI design. Is there any way to do it?

1

There are 1 best solutions below

2
On

Yes, in your mirage/config.js:

let pollNum = 0;

this.get('/api/poll', () => {
  pollNum++;
  if (pollNum > 2) {
    return { success: true }; // replace with your success fixture
  } else {
    return { success: false }; // replace with your in progress fixture
  }
});