# Code Generation: Node

**URL:** <https://community.postman.com/t/code-generation-node/8497>\
**Category:** Help Hub\
**Created:** [October 22, 2019, 11:09am UTC](https://community.postman.com/t/code-generation-node/8497 "2019-10-22T11:09:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trisyswhatsapp](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/trisyswhatsapp/32/1371_2.png) [@trisyswhatsapp](https://community.postman.com/u/trisyswhatsapp)\
**Post date:** [October 22, 2019, 11:09am UTC](https://community.postman.com/t/code-generation-node/8497/1 "2019-10-22T11:09:13Z")

</div>

Your code generator for Node is very good at the top, then tails away, for example at the start, this is good:

```auto
var https = require('https');

var options = {
  'method': 'POST',
  'hostname': ....
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });
...

```

However, this code is not so good:

```auto
var postData = "{\n\tFieldName: 'data'\n}";
req.write(postData);
req.end();

```

May I suggest that this last bit uses proper JSON objects rather than strings which are simply yuk!

Everything else is coming along nicely 😉

---

<div class="post-metadata">

**Author:** ![trisyswhatsapp](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/trisyswhatsapp/32/1371_2.png) [@trisyswhatsapp](https://community.postman.com/u/trisyswhatsapp)\
**Post date:** [October 22, 2019, 11:17am UTC](https://community.postman.com/t/code-generation-node/8497/2 "2019-10-22T11:17:50Z")

</div>

Even this JQuery code:

```auto
var settings = {
  "url": "https://postman.com/security/authenticate",
  "method": "POST",
  ...
  "data": "{\r\n\tFullName: '{{FullName}}',\r\n\tPassword: '{{Password}}'\r\n}"
};

```

Should be re-written as:

```auto
var credentials = {
    FullName: '{{FullName}}',
    Password: '{{Password}}'
};
var sJSON = JSON.stringify(credentials);

var settings = {
  "url": "https://postman.com/security/authenticate",
  "method": "POST",
  ...
  "data": sJSON
};

```

Much easier to read, agree?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 22, 2019, 11:22am UTC](https://community.postman.com/t/code-generation-node/8497/3 "2019-10-22T11:22:53Z")

</div>

Hey @trisyswhatsapp,

These are good points that I don’t want to get missed on this public community forum - Can you submit these suggestions on the Code Gen Github repo please, so that the team can prioritise any work that needs to get done.

> **[Issues · postmanlabs/postman-code-generators](https://github.com/postmanlabs/postman-code-generators/issues)**
>
> Common repository for all code generators shipped with Postman - Issues · postmanlabs/postman-code-generators

---

<div class="post-metadata">

**Author:** ![trisyswhatsapp](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/trisyswhatsapp/32/1371_2.png) [@trisyswhatsapp](https://community.postman.com/u/trisyswhatsapp)\
**Post date:** [October 22, 2019, 11:48am UTC](https://community.postman.com/t/code-generation-node/8497/4 "2019-10-22T11:48:40Z")

</div>

Hi Danny

Thanks for replying. I have posted on Github as requested.

Kind Regards, Garry.
