Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Related Rants
1. getSomeData(params, ((err, data) => {
2. if(!err && data) {
3. try {
4. data = JSON.parse(data);
5. } catch(e) {
6. return null;
7. }
8. return data.someParam;
9. }
10.}
Nothing like bad practice in above code but I always feel that the line 4 should be replaced by below.
4. var result = JSON.parse(data);
and then use result variable to get data one is looking for, like below
8. return result ? result.someParam : null;
Your thoughts?
undefined
wk47