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

244
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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