trisys
(Garry Lowther)
October 22, 2019, 11:09am
1
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) {
chunks.push(chunk);
});
...
However, this code is not so good:
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
trisys
(Garry Lowther)
October 22, 2019, 11:17am
2
Even this JQuery code:
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:
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?
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.
trisys
(Garry Lowther)
October 22, 2019, 11:48am
4
Hi Danny
Thanks for replying. I have posted on Github as requested.
Kind Regards, Garry.
1 Like