Created
          September 7, 2020 23:33 
        
      - 
      
- 
        Save MeliAlbu/6cf6b5eb26895735d14a50a7c68d1e49 to your computer and use it in GitHub Desktop. 
    list
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import React, { useState, useEffect } from "react"; | |
| import Item from "../Navbar/Item"; | |
| export default function List() { | |
| const [items, setItems] = useState({}); | |
| useEffect(() => { | |
| fetchData(); | |
| }, []); | |
| async function fetchData() { | |
| const getData = await fetch( | |
| "https://api.mercadolibre.com/sites/MLA/search?q=zapatillas" | |
| ); | |
| const getJson = await getData.json(); | |
| setItems(getJson.results); | |
| console.log(getJson); | |
| console.log("holasa,", getJson.results); | |
| } | |
| useEffect(() => { | |
| fetchData(); | |
| }, []); | |
| return ( | |
| <> | |
| {items.map((item, key) => { | |
| return <Item data={item} key={item.id ? item.id : key} />; | |
| })} | |
| </> | |
| ); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment