Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
JS filter and some methods behaving different server side

I am getting different results using JS filter and some methods when running within my node js app (server side) and in the browser console (client side)

I have the following 2 arrays of objects, and what I want to achieve is to create a new array of objects that does not include anything that is duplicated

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 });
}

Logging out alertsToSet in the browser is empty, which is the desired behaviour, but when running this code server side, alertsToSet has 2 objects

Am i missing something or made a mistake ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda