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

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

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