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

207
Vistas
Parsing Axios URL Param to String Array in ExpressJS

Sending a GET Request with axios:

await this.client.get('/endpoint', { params: { query: ['max', 'kevin'] } })

Results in a URL looking like this

Request GET /endpoint?query[]=max&query[]=kevin

How can I parse this to a string array?

Bonus points if someone knows how to check it in express-validator for format!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can turn the array to string with to toString:

await this.client.get("/endpoint", {
  params: { query: ["max", "kevin"].toString() },
});

This will change the URL to:

/endpoint?query=max,kevin

Then in the express-validator you can validate the array items with wildcard:

req.check('query.*').isLength({ max: 30 })
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