Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created October 9, 2018 08:40
Show Gist options
  • Save amandeepmittal/6b2c44251cee554b42f7d8aeeae1572c to your computer and use it in GitHub Desktop.
Save amandeepmittal/6b2c44251cee554b42f7d8aeeae1572c to your computer and use it in GitHub Desktop.
import axios from 'axios';
export default {
// Gets all books
getBooks: function() {
return axios.get('/api/books');
},
// Gets the book with the given id
getBook: function(id) {
return axios.get('/api/books/' + id);
},
// Deletes the book with the given id
deleteBook: function(id) {
return axios.delete('/api/books/' + id);
},
// Saves a book to the database
saveBook: function(bookData) {
return axios.post('/api/books', bookData);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment