-1

I'm pretty new to nodeJS so please forgive me, if I ask stupid questions.

What I want to do:

I have two (or more) variables

var a = "test";
var b = "1234";

i want to make an object (for an http.request - which will get JSON.stringify'ed before passing it to the next host) with those two variables like:

var data = {
    a : b
}

It seems this is pretty impossible, as node keeps jelling about it - or maybe I misunderstood something wrong...

var data1 = {
    name: a,
    2ndname: b
}

of course works but the reason, why I want to achieve this is I'm getting a "huge" JSON response from a webservice, where I want to pick out some parts (sometime 4 values, sometimes 15...) and forward them to another host to index, without "reformatting" the values.

Maybe someone can help me with this, or maybe I'm missing some "feature" of NodeJS which could do this in a proper way.

Thank you in advance

1 Answers1

0

Part of the solutions I found at Convert an array to an array of objects

Referencing at the construction mentioned above:

var data = {
    [a] = [b];
}

I hope maybe it helps somebody (like me) in the future :-)

Community
  • 1
  • 1