Basically I've been stuck for days unsure of what the error is. My get request for all books works
export const getBooks = async () => {
try {
const response = await api.get('/books')
return response.data
} catch (error) {
throw error
}
}
Trying to get an individual book fails to grab it by the id
export const getBook = async id => {
try {
const response = await api.get(`/books/${id}`)
return response.data
} catch (error) {
console.log("This is the problem")
}
}
I can see and console the array of objects in localhost:3000/api/books in my app, but get CANNOT GET if I try to see a specific object by index number i.e localhost:3000/api/books/1 or localhost:3000/api/books/434r47r3g738384 ( by the specific :id)
This is the error when I inspect.
Request URL: http://localhost:3000/api/books/62bdf9227dfc85a4a55fd4c7 Request Method: GET Status Code: 404 Not Found Remote Address: [::1]:3000 Referrer Policy: strict-origin-when-cross-origin
404 usually means that the resource can't be found (most likely that books/1 doesn't exist). if that uri did exist, but found nothing, it would normally be like a 204 (no content) status. You may need to look again at your endpoints.