Alrefai / capstone-project-2-expresso

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

api

Axkaban opened this issue · comments

89 passing tests! Congrats!

Nice use of ternary operators.

Good implementation of string interpolation throughout the project.

In situation when you're passing a callback with 'row' argument, I know it is common to have row but you can also use the item name since 'row' is only a parameter, if you were to change it to the item's name, you could take advantage of destructuring and only pass the value to the object that is being sent which will become key and value.
For example, in:

  function(err) {
      if (err) { return next(err) }
      db.get(`SELECT * FROM Timesheet WHERE id = ${timesheetId}`,
        (err, row) => {
          if (err) { return next(err) }
          res.send({ timesheet: row });
        }
      );
    }

Your callback (err, row) => {...} can be (err, timesheet) =>{..} so when you send the response, you only need to write:
res.send({ timesheet }); where timesheet becomes the name of the key but as a value is the argument object passed.

Great advice! Thanks.