Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

89
Vistas
React JS API item.map

import React, { useState, useEffect, } from "react";

function ProductDetail({match}) {
useEffect(() => {
  fetchItem();
  // console.log(match)
}, );

const fetchItem = async () => {
  const fetchItem = await fetch(`https://fortnite-api.theapinetwork.com/item/get?id={{itemid}}`);
  const item = await fetchItem.json();

  console.log(item);
}

  return (
    <div className="containter productsDetails">
      <h1>Product Detail</h1>
    </div>
  );
}

export default ProductDetail;

enter image description here

import React, { useState, useEffect } from "react";
import {Link} from "react-router-dom";

function Products() {
  const [data, setData] = useState([]);

  const apiGet = () => {
    fetch(`https://fortnite-api.theapinetwork.com/items/popular`)
      .then((response) => response.json())
      .then((json) => {
        console.log(json);
        setData(json);
      });
  };

  useEffect(() => {
    apiGet();
  },[])

  return (
    <div>

      <div>
          <ul>
              {data.map(item =>
              <li  key={item.id}>
                  <Link to={`/products/${item.id}`}>{item.item}</Link>
              </li>
                )}
          </ul>
      </div>
    </div>
  );
}

export default Products;

I have tried every way I can find online.

I am unable to map into the entries object of this API. I would like to map to the 3 array objects.

So that I can {match} using an ID when I click one of them.

The routing is working. But I can not display any of the data on the screen. In Console it is displaying.

He is the API fortnite-api.theapinetwork.com/items/popular

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You're trying to use map function on object. map only works for arrays.

Here's the link to sandbox how it should be

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda