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

553
Views
obteniendo este error en el nodo jd error: TypeError: No se puede leer la propiedad '0' de indefinido

hola, estoy tratando de implementar un libro de pedidos local usando la api de binance, sin embargo, sigo recibiendo este error de vez en cuando, no siempre sucede, pero si sucede, sucederá desde el principio, por favor ayuda

este es el archivo principal que se ejecuta llamando a una función de exportación desde un archivo externo para procesar los datos provenientes del socket web en el mensaje

 wsClient.subscribeSpotDiffBookDepth("btcusdt"); wsClient.on('message', (data) => { // Setup and process order book information order_book.update_orderbook(data); if(order_book.ready === 1){ order_book.get_orderbook_history(); } }); wsClient.on('error', err => { /* handle error */ console.log("this is it 2 " + err); }); wsClient.on('close', () => { /* ... */ });

función de exportación en archivo externo

 exports.update_orderbook = function(data) { if(data.e == "depthUpdate"){ if(this.ready === 0){ this.ready = 1; console.log("Stage 1 in play"); }else{ this.buffer += data; } if(this.ready === 2 && this.asks != null && this.bids != null){ if(undefined !== this.asks && undefined !== this.bids && undefined !== data.a && undefined !== data.b){ if(data.U <= this.lastUpdateId + 1 && data.u >= this.lastUpdateId + 1){ // error is coming from calling this function------------------------------------------------------- var temp_array1 = sort_array(this.asks, data.a); var temp_array2 = sort_array(this.bids, data.b); this.asks = temp_array1; this.bids = temp_array2; this.lastUpdateId = data.u; console.log("Stage 3"); } } }else{ this.buffer += data; } } }

función para ordenar y actualizar la matriz

 function sort_array(array1, array2){ for(let x in array2){ if(array2[x][1] == 0){ for(let i in array2){ if(array1[i][0] === array2[x][0]){ array1.splice(i, 1); } } }else{ var in_array = false; for(let i in array1){ // this seems to be the problem area--------------------------------------------------------- if(array1[i][0] === array2[x][0]){ array1[i] = array2[x]; in_array = true; } } if(!in_array){ array1.push(array2[x]); } } } return array1; }

registro de errores

ingrese la descripción de la imagen aquí

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!