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

130
Vistas
What is the correct way to make api requests in react?

I’ve tried to apply for a job. I had to make an application and one of the tasks was to use an api call for images.

I’ve used Axios inside a function inside a useEffect hook. With async await.

The application worked very well.

But the feedback they gave me was that I did’t use api calls correctly. I’ve asked them to be more specific but they didn’t respond yet, unfortunately :/ Does anyone know what I could’ve done differently. And it also was a bonus task lol.

How would you approach this?

The task:

Get some (random) mushroom images from a image api.

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

0

To fetch data in React using useEffect and Axios, you can do something like this:

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

function Axios() {
  const [data, setData] = useState(null); // to store your data
  useEffect(() => {
    // your URL goes here
    axios.get("https://mushroom/api/image/random").then((resp) => {
      setData(resp.data.message);
    });
  }, []);
  return (
    <div>
      <img width={500} src={data} />
    </div>
  );
}

export default Axios;

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