For the More Curious: Ember CLI Mirage

One the most common blockers for front-end application development is the API. A number of problems can come up: the API might not have been created, the API might be in development, or the API might be behind a firewall while you are developing.

The easiest solution to an inaccessible API is using static text or fixture data. But this solution might introduce a number of other issues, like changing the application logic to suit the inaccessible data, changing the requests to this.store, or changing the adapter or serializer.

Ember CLI Mirage is an addon that will proxy the requests to specific API routes. You can set up models to establish relationships, set up factories to seed data, create fixture data for specific responses, and define CRUD routes to intercept specific requests to the API. Once these are set up, you can develop as though the API were in place.

While Mirage is enabled, all requests will be diverted to the local Mirage setup.

At the time of printing, ember-cli-mirage is in version 0.2.0-beta.8. You are going to explore Mirage in just a moment as part of a challenge. To find out more about Ember CLI Mirage, visit www.ember-cli-mirage.com.

In the next chapter, you will bring together the concepts of the last three chapters and create a working application that routes requests and displays data. In Chapter 24, you will create, edit, and delete content. You will see the power of Ember Data, adapters, and serializers when you can call save and destroyRecord on models and your data is sent to the API without much heartache.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.122.244