...

/

Solution: Create the About and Dashboard Routes

Solution: Create the About and Dashboard Routes

Go over the solution to implement the about and dashboard routes and limit access to the dashboard route.

We'll cover the following...

Solution

The following is the complete implementation of the problem described here:

'use strict'

class ConvertEmptyStringsToNull {
  async handle ({ request }, next) {
    if (Object.keys(request.body).length) {
      request.body = Object.assign(
        ...Object.keys(request.body).map(key => ({
          [key]: request.body[key] !== '' ? request.body[key] : null
        }))
      )
    }

    await next()
  }
}

module.exports = ConvertEmptyStringsToNull

Press Run and wait for the output to ...