Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
GET request to API Id not found, request to entire API works

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

REST API 404: Bad URI, or Missing Resource?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!