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

318
Views
javascript websocket error, I want to get event.data in global scope

I want extract real time data from binance websocket. but result error.

let socket = new WebSocket("wss://stream.binance.com:9443/ws/btcusdt@trade");

        socket.onmessage = function(event){
        let current_price = JSON.parse(event.data);
        
        // console.log(current_price); :is okay!

        return current_price;
        }

let Data = socket.onmessage();

console.log(Data); :not okay..

even.data in function scope has no error,
but event.data not in function scope has this error.
Uncaught TypeError: Cannot read properties of undefined (reading 'data')

I want to get even.data in global scope.

plz help.

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!