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

189
Views
React access to value api

I'm creating a book finder app using google book api. But I can get from the api only the kind value and not the title and the authors I leave here the code

    const getData = async () => {
        const response = await axios.get(url);
        console.log(response); // 2) Passo funzione utile a fetchare dei dati dall'api con axios al url
        setBooks(response.data.items);
      };
      useEffect(() => {
        // 3)Passo abbiamo settato il nuovo array dai dati presi da getData che li prendeva dall'api
        getData(); // Chiamata all'interno di una funzione in useEffect perche lo use effect non può essere asyncrono
      }, []); // Clean up cosi gli diciamo che vogliamo che venga chiamato solo al primo render se no va in loop senza
      return (
        <>
        <ul>
          {
            books.map( el => {
              const {kind, id, title} = el
              return <li key={id} className="shadow">
                <h5>{title}</h5>
              </li>
            })
          }
        </ul>
      </>
    );
    };

here the api

  "kind": "books#volumes",
  "totalItems": 2,
  "items": [
    {
      "kind": "books#volume",
      "id": "5svUwAEACAAJ",
      "etag": "ag5tZElp08M",
      "selfLink": "https://www.googleapis.com/books/v1/volumes/5svUwAEACAAJ",
      "volumeInfo": {
        "title": "Year Book",
        "subtitle": "The Annual Supplement to the World Book Encyclopedia : the 1989 World Book : a Review of the Events of 1988",
        "authors": [
          "World Book Encyclopedia"
        ],

thanks for the help

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just add if after useEffect, and set by default state books null

const [books, setBooks] = useState(null)
// Your code
if (!books) return <h1>Loading...</h1>
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!