Skip to content

Commit

Permalink
allow no title or body when creating note
Browse files Browse the repository at this point in the history
  • Loading branch information
trdecker committed Nov 26, 2023
1 parent 2fd761e commit 0205303
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/controllers/noteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ const notesController = {
return
}

if (!newNote.title) {
apiBadRequestError(res, 'title is a required field in the body')
return
}

if (!newNote.body) {
apiBadRequestError(res, 'body is a required field in the body')
return
}
// if (!newNote.title) {
// apiBadRequestError(res, 'title is a required field in the body')
// return
// }

// if (!newNote.body) {
// apiBadRequestError(res, 'body is a required field in the body')
// return
// }

const createdItem = await noteModel.createNote(userId, newNote)
res.json(createdItem)
Expand Down
2 changes: 2 additions & 0 deletions src/utils/apiUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function apiBadRequestError(res, errorMessage) {

export function apiForbiddenError(res, errorMessage) {
res.status(403).send(errorMessage)
console.error(errorMessage)
}

/**
Expand All @@ -20,6 +21,7 @@ export function apiForbiddenError(res, errorMessage) {
*/
export function apiNotFoundError(res, errorMessage) {
res.status(404).send(errorMessage)
console.error(errorMessage)
}

/**
Expand Down

0 comments on commit 0205303

Please sign in to comment.