Code Generation: Node

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

var https = require('https');

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

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

  res.on("data", function (chunk) {

However, this code is not so good:

var postData =  "{\n\tFieldName: 'data'\n}";

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

Everything else is coming along nicely :wink:

Even this JQuery code:

var settings = {
  "url": "",
  "method": "POST",
  "data": "{\r\n\tFullName: '{{FullName}}',\r\n\tPassword: '{{Password}}'\r\n}"

Should be re-written as:

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

var settings = {
  "url": "",
  "method": "POST",
  "data": sJSON

Much easier to read, agree?

Hey @trisys,

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.

Hi Danny

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

Kind Regards, Garry.

1 Like