• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

194
Views
How do I convert a Nest request object with a buffer into JSON?

How do I convert a Nest request object with a buffer into JSON? Everything I've logged either shows an array of bytes or a string.

Here is my controller:

export class KycresultsController {
  @Post()
  create(@Body() data: any): string {
    const j = data.toJSON();

    var buf = Buffer.from(JSON.stringify(data));
    var temp = JSON.parse(buf.toString());
    var f = temp.data;
    console.log(f);

    const decodedJsonObject = Buffer.from(f, 'base64').toString('ascii'); 
    console.log(decodedJsonObject);`

And I send this POST:

curl -X POST localhost:3001/kycresults -d "emsample=1&data=2"

I see in my logs:

[
  101, 109, 115, 97, 109, 112,
  108, 101,  61, 49,  38, 100,
   97, 116,  97, 61,  50
]
emsample=1&data=2
[
  101, 109, 115, 97, 109, 112,
  108, 101,  61, 49,  38, 100,
   97, 116,  97, 61,  50
]
emsample=1&data=2

I want to get {emsample: 1, data: 2}

about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error