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

216
Views
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 answers
Answer question

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