I have this update method and I have read that axios uses put instead of patch to update a record, so I'm trying to update a record on my rails Api from my Vue js app but it gives back a 404 error.
How can I solve it?
updateBook() {
const book = {
book_id: this.books.id,
book_title: this.books.id,
author_id: this.books.author_id,
genre_id: this.books.genre_id,
set bookTitle(title) {
this.book_title = title;
},
set authorId(id) {
this.author_id = id;
},
set genreId(id) {
this.genre_id = id;
},
get title() {
return this.book_title;
},
get id() {
return this.book_id;
},
};
book.bookTitle = this.book_title;
book.authorId = this.author_id;
book.genreId = this.genre_id;
axios.put('http://localhost:3000/api/v1/books/', book.id)
.catch((error) => { console.log(error); });
},
http://localhost:3000/api/v1/books/is working? 404 usually means that the end point was not found..putwork: github.com/axios/axios#axiosputurl-data-config. Try`http://localhost:3000/api/v1/books/${book.id}`as the URL instead.