Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

312
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda