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

241
Views
How to pass values from an array to filter clause while hitting a url

I have the below student values in an array

var arr=['sam','peter','alex']

Now I am hitting an endpoint where in I need to filter out the values based on the student names as follows.

***************/$format=json&$filter=name eq 'sam' or name eq 'peter' or name eq 'alex'&$select=id,address

getData is a custom function to connect to db and performs odata call Below is the implementation I have used.

getData([
                    `/student_details`,
                    `?$format=json`,
                    `&$filter=name eq '${arr}'`,
                   `&$select=id,address`
                ])

the length of the names array is not constant and it keeps varying. The above piece of code doesn't work and instead the url is framed as

***************/$format=json&$filter=name eq 'sam,peter,alex'&$select=id,address

How do I correct this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just use declare a variable query that later on you will use in your getData function:

var arr=['sam','peter','alex'];

var query = arr.map(e => `name eq "${e}" `).join('or ');

console.log(query);

getData([
    `/student_details`,
    `?$format=json`,
    `&$filter='${query}'`,
    `&$select=id,address`
]);

`

about 4 years ago · Juan Pablo Isaza Report
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!