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

127
Views
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
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!