Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda