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

91
Views
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 answers
Answer question

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 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!