Skip to main content
highlighted:

Response method

Custom responses functions extends express.js response object (res) with some extras functions like res.ok, res.updated.

Core responses:

res.ok() send a 200 response

Use to send simple success responses or find and findAll responses

res.ok();

res.notFound send a 404 response

Use to show the not found page

res.notFound(msg);

res.forbidden send a 403 response

Use to send the forbidden page

res.forbidden(msg);

res.serverError send a 403 response

Use to send the error page

res.serverError(err);

res.badRequest send a 400 response

Use to send the bad request page

res.badRequest(msg);

res.queryError send a 400 or 403 response

Use in sequelize .catch callback for parse database errors and for html requests will reload the form with erro messages

we.db.models.user.findOne()
//.then(...)
.catch(res.queryError);

res.goTo a core redirect how use flash for deals with session messages

Use for redirects

res.goTo(responseStatus, pathOrUrl);

Record responses:

res.created() send a 201 response with suport to core redirecTo

Use after create a record

res.created();

res.updated() send a 200 response with suport to core redirecTo

Use after update a record

res.updated();

res.deleted() send a 204 response with suport to core redirecTo

Use after delete a record

res.deleted();


afterContent:
Widget: Comments 13:

Comments