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

119
Views
Function running after data loading still gives an error because data is not loaded

I am getting Binance coin data from Binance npm package. But when I try to run filter or map function it gives the error: TypeError: Cannot read properties of undefined (reading 'filter')

The code:

const client = Binance();

  const [dataLoading, setDataLoaded] = useState(true);
  const [tradesData, setTradesData] = useState();
  const [length, setLength] = useState();

  const tradesDataSet = async () => {
    setTradesData(await client.trades({ symbol: "BTCUSDT" }));

    setDataLoaded(false);
  };

  useEffect(() => {
    tradesDataSet();
  }, []);
  console.log(
    tradesData.filter((trade) => trade.price * trade.qty > 3000).length
  );

How do I troubleshoot?

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!