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

214
Vistas
How to get URL query withouth parsing it in NestJS

Hello everyone I am trying to just get my route with all query params as it is, withouth parsing it. My route is something like this:

http://somewebsite/orders?key1=value1&key=value

I don't want to use

@Query()

that returns the object with key/value pairs I just want to get plain string value of everything that is behind ? so I want to get something like this

string = "key1=value1&key=value"

edit

controller.ts

@Get('/orders')
getOrders(
    @Query(ValidateQueryPipe) query: QueryParameters): Subscription {
    // here I want to have my query as a string not as an object. 
    })
}

so when I send a request to my route from let's say postman I will be able to have all the key/value pairs I pass but as a string...

Thanks

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

0

Try to pass the request object to your function and get the originalUrl, where the query string should be located

import { Req } from '@nestjs/common';
import { Request } from 'express';

getOrders(@Req() request: Request): Subscription {
  const regex = /(?<=\?).*$/gm;
  const result = request.originalUrl.match(regex);

  if (result) {
    const query = result[0];
  }
}
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