DavidoVitch
DavidoVitch

Reputation: 91

NodeJS : Need Help To build object with some Brackets and Braces

In my project I use request lib () and i would like to use qsStringifyOptions for query parametre but it's to much complicated in my case :/

In their documentation they link qs module to use qsStringifyOptions like them

I would like to have this URL

http://127.0.0.1:80/endpoint?foo=bar[baz:3]&aaa=[{baa:X,caa:XX,daa:[{eaa:Z,faa:ZZ}]}]&data[B]=BB&data[C]=CC

but I have this URL:

http://127.0.0.1:80/endpoint?foo=bar[baz:3]&aaa=[%7B%22baa%22:%22X%22,%22caa%22:%22XX%22,%22daa%22:[%7B%22eaa%22:%22Z%22,%22faa%22:%22ZZ%22%7D]%7D]&data[B]=BB&data[C]=CC

With this solution, the 'foo' attribute and data[B] and data[C] work fine but 'aaa' attribut not at all :

{ // some standar param URI, methode ...
    useQuerystring: false,
    qsStringifyOptions : {encodeValuesOnly: true, encode: false,  indices: false},
    qs : {
      foo: 'bar[baz:1]',
      aaa:'[{"baa":"X","caa":"XX","daa":[{"eaa":"Z","faa":"ZZ"}]}]',
      data: {B:'BB', C:'CC'}
    }
}

what i'm doing wrong? i just want it not to parse the 'aaa' attribute thank you in advance for your help and your time

Upvotes: 0

Views: 69

Answers (0)

Related Questions