Skip to content
This repository was archived by the owner on Oct 29, 2019. It is now read-only.
This repository was archived by the owner on Oct 29, 2019. It is now read-only.

Replace callbacks with async/await in smallgroup.controller.js  #792

@aeksco

Description

@aeksco

All our Express.js controllers use callbacks when interacting with our Mongoose models - like so:

exports.index = (req, res) => {
    SmallGroup.find({}, (err, smallgroups) => {
        if (err) { return handleError(res, err); }
        return res.status(200).json(smallgroups);
    });
};

These functions should be updated to use the async/await syntax, like so:

exports.index = async (req, res) => {
  const smallgroups = await SmallGroup.find({}).catch((err) => { return handleError(res, err); })
  return res.status(200).json(smallgroups);
};

@TungE LMK if you've got any questions - sorry for the delay!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions