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

138
Views
Filtro JS y algunos métodos que se comportan en diferentes lados del servidor

Estoy obteniendo diferentes resultados usando el filter JS y some métodos cuando ejecuto dentro de mi aplicación node js (lado del servidor) y en la consola del navegador (lado del cliente)

Tengo las siguientes 2 matrices de objetos, y lo que quiero lograr es crear una nueva matriz de objetos que no incluya nada que esté duplicado

 export default async (req, res) => { const userAlerts = req.body; console.log(userAlerts); userAlerts = [ { user_id: 232, match_id: 3918053, alert_type: 'OVER0.5FHCORNERS', alert_odds: '2.0', home_team: 'Pescara U19', }, { user_id: 232, match_id: 3909005, alert_type: 'OVER0.5FHCORNERS', alert_odds: '2.0', home_team: 'Fortuna Koln U19', } ] const existingAlerts = await queries.getUserTelegramAlerts(userID); console.log(existingAlerts); existingAlerts = [ { user_id: 232, match_id: 3918053, alert_type: 'OVER0.5FHCORNERS', alert_odds: '2.0', home_team: 'Pescara U19', }, { user_id: 232, match_id: 3909005, alert_type: 'OVER0.5FHCORNERS', alert_odds: '2.0', home_team: 'Fortuna Koln U19', } ] const alertsToSet = userAlerts.filter(x => { return !existingAlerts.some( t => t.user_id === x.user_id && t.match_id === x.match_id && t.alert_type === x.alert_type && t.alert_odds === x.alert_odds ); }); console.log({ alertsToSet }); }

El cierre de sesión de alertsToSet en el navegador está vacío, que es el comportamiento deseado, pero cuando se ejecuta este código del lado del servidor, alertsToSet tiene 2 objetos

¿Me estoy perdiendo algo o cometí un error?

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!