Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

314
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda