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

121
Visualizações
Cant get data with Axios

I'm trying to learn basic React I want to build the cocktail page which allows the user to search for specific cocktails I've used cocktailsdb API but and tried to use Axios but when I'm trying to search the result won't come out because there is no data. I don't know the source for this problem image

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The issue is because you've got a line break here: https://github.com/MatanSofer/Cocktail-Bar/blob/e21c5cc266c23cb2e47e26ea31de102ef26d791f/components/search/Search.js#L27

Particularly this line:

axios
      .get(`https://thecocktaildb.com/api/json/v1/1/search.php?s=
      ${term}`)  //pay attention is the letter next to digit 1

If you look at the network request, you'll see a tun of spaces preceding the search term.

invalid search term

If you change that line to:

 axios
      .get(`https://thecocktaildb.com/api/json/v1/1/search.php?s=${term}`)

It works fine:

enter image description here

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