Skip to content

Commit

Permalink
Update: bookSlice to send requests to correct endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaytonSiby committed Oct 11, 2023
1 parent 0f9bdc1 commit 79dc518
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/features/book/bookSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ export const fetchBooks = createAsyncThunk('books/fetchBooks', async () => {
return response.data
})

export const fetchBook = createAsyncThunk('books/fetchBook', async (id) => {
const response = await axios.get(
`https://helm-bookstore-api.onrender.com/api/books/${id}`
)
return response.data
})
export const fetchBook = createAsyncThunk(
'books/fetchBook',
async (id: string) => {
const response = await axios.get(
`https://helm-bookstore-api.onrender.com/api/books/${id}/`
)
return response.data
}
)

export const addBook = createAsyncThunk('books/addBook', async (book: Book) => {
try {
Expand Down Expand Up @@ -64,7 +67,7 @@ export const updateBook = createAsyncThunk(
'books/updateBook',
async (book: Book) => {
const response = await axios.put(
`https://helm-bookstore-api.onrender.com/api/books/${book.id}`,
`https://helm-bookstore-api.onrender.com/api/books/${book.id}/`,
book
)
return response.data
Expand Down

0 comments on commit 79dc518

Please sign in to comment.