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

167
Views
Error undefined when atributing value to variable

Given this response from a http request.

[{"_id":"Castanho","count":7,"state":[{"state":"rejected","count":1},{"state":"pending","count":4},{"state":"approved","count":2}]},

{"_id":"Preto","count":1,"state":[{"state":"pending","count":1}]},

{"_id":"Azul","count":1,"state":[{"state":"pending","count":1}]}]

export default function StatisticsDashboard(props) {
const [dataSt, setDataSt] = useState();

useEffect(() => {
    async function fetchData() {
        const res = await client.get("/statistics");
        const data=res.data;
        console.log(data);
        setDataSt(data);
        console.log(dataSt);
    }
    fetchData();
}, []);

Why doesnt set the DataSt with the request data? I even tried to create a aux const named data (on the code example) to see if worked.

Screenshot of the console.log output

The undefined is from the console.log(dataSt);

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!