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

120
Views
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 answers
Answer question

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 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!