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

192
Views
Reaccionar acceso a valor api

Estoy creando una aplicación de búsqueda de libros usando la API de Google Book. Pero puedo obtener de la api solo el valor del tipo y no el título y los autores, aquí dejo el código.

 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> </> ); };

aquí la 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" ],

gracias por la ayuda

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

0

Simplemente agregue if después de useEffect , y configure de forma predeterminada los libros de estado 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!