In the previous recipe, we retrieved already existing book data from our mock server and displayed it to the user. Ember Data also has the ability to create, delete, and even update records from the data store. We will be looking at these methods and more.
Just like the previous example, we'll need to install Ember CLI Mirage. Take a look at the previous recipe for instructions on this process. We'll be using the same factories as the book recipe and we'll be adding new methods to add, edit, and delete data.
In the
mirage
folder, open theconfig.js
file:// app/mirage/config.js export default function() { this.get('/books'); this.get('/books/:id'); this.put('/books/:id'); this.post('/books'); this.delete('/books/:id'); }
This will mock our backend and allow us to create, update, and delete data. This is done using the HTTP PUT, POST, and DELETE requests. We'll use this later in our program.
Update...