Improve code quality in API helpers.js
Closed this issue · 1 comments
aeksco commented
Update the handleError
function to return { error: err }
and set status
manually, like so:
// Return a standard error
export const handleError = (res, err) => {
return res.status(500).json({ error: err }).end()
}
Repeat this process for the validationError
function.
Additionally:
- replace all
var
statements with eitherlet
orconst
. - Make whitespace consistent in file (i.e.
if(err){ ...
should beif (err) { ...
) - Replace
"
(double quote) with'
(single quotes) - Replace
function
keyword with=>
function syntax, i.e.:
this:
ClassYear.findOne({"dayCodes.code":code})
.exec(function(err, classYear){
...
})
becomes:
ClassYear.findOne({"dayCodes.code":code})
.exec((err, classYear) => {
...
})
aeksco commented
Resolved