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

256
Views
passing data from one API endpoint to another in ReactJS

what would be the best way to get data from an API (https://nba-players.herokuapp.com/players-stats-teams/lal), run a function on it and save results, then use that data to call a different API endpoint (e.g. https://nba-players.herokuapp.com/players/curry/stephen)? To be more specific, I'm trying to display an image of each player in an Avatar component using the first and last name of each player (full name obtained from API call in App.js, so I would have to split and store (hook? object?) into first and last name). I map through each player in App.js. I note the API itself is pretty basic. Also dealing with 2 API calls in react

Thank you

App.js: 
 
import React, { useEffect, useState } from "react";
import axios from "axios";
import Card from "./Card";


function App() {
  const [data, setData] = useState([]);
  const team = "lal";
  const url = "https://nba-players.herokuapp.com/players-stats-teams/" + team;

  const getData = async () => {
    try {
      const teamPlayersData = await axios.get(url);
      setData(teamPlayersData.data); 
    } catch (err) {
      console.error(err.message);
    }
  };

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

  return (
    <div>
      {data.map((player, index) => (
        <Card
          key={index}
          name={player.name}
          img={getImage(player)} QQQ THIS PART 
          team={player.team_name}
          rating={player.player_efficiency_rating}
        />
      ))}
    </div>
  );
}

export default App;
Card.js

import React from "react";
import Avatar from "./Avatar";

function Card(props) {
  return (
    <div className="card">
      <li>{props.name}</li>
      <Avatar img={props.img} /> QQQ
      <li>{props.team}</li>
      <li>{props.rating}</li>
    </div>
  );
}

export default Card; 
Avatar.js
*call different API endpoint here to retrieve image, run function to split full name into first and last name in this file? 

function Avatar(props) {
  return <img src={props.img} alt="avatar_img" />;
}

export default Avatar;
about 4 years ago · Juan Pablo Isaza
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!