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

257
Vistas
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
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