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

400
Views
Trouble parsing data :Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

I'm having a little trouble understanding this error: Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

I've tried parsing the data to see if anything would show but it still displays blank any help would be appreciated

    import React, { useState} from 'react';
function Drinks  ()  {
  //if nothing is entered it defaults to Blue Margarita
const[drinks, setDrinks] = useState("Blue Margarita");


function handleChange(e){
    setDrinks(e.target.value);
}
// 'margarita'
 function getDrinks(){ 
  // www.thecocktaildb.com/api/json/v1/1/search.php?s=margarita
   fetch(`www.thecocktaildb.com/api/json/v1/1/search.php?s=${drinks}`)
    .then((res)=> res.json())
    .then((data)=>{
        setDrinks(data)
        console.log(data);
    })
    // .catch(()=> {
    // console.log("err")
      
    // });
};

  return (
  <article>
    <div>
        <input type="String"placeholder="Enter a drink"
        onChange={handleChange}/>
        <button className="btn"onClick={getDrinks}>getDrink</button> 
    </div>

   <h1>{getDrinks.strDrink}</h1> 
   <h2>{getDrinks.idDrink}</h2>

  </article>
  

  

  )
}

export default Drinks
about 4 years ago · Juan Pablo Isaza
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!