Skip to content

Missing return in thing.controller.js which causes Promise warning. #2412

@JoelParke

Description

@JoelParke
  • I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests.
Item Version
generator-angular-fullstack 4.1.1
Node 4.4.4
npm 3.10.5
Operating System Ubuntu 16.10
Item Answer
Transpiler TypeScript
Markup HTML
CSS SCSS
Router ui-router
Client Tests Mocha
DB MongoDB
Auth Y

Missing return in thing.controller.js at line 43:
WHICH causes

Warning: a promise was created in a handler at angular-fullstack/server/api/thing/thing.controller.js:43:27 but was not returned from it,

Change:

       function removeEntity(res) {
            return function(entity) {
            if(entity) {
              return entity.remove()
                .then(() => {
                  res.status(204).end();
                });
            }
          };
        }

to:

         function removeEntity(res) {
             return function(entity) {
                 if(entity) {
                   return entity.remove()
                    .then(() => {
------>                       return res.status(204).end();
                    });
                 }
             };
         }

The fix above is better changed too below, because otherwise the eslint: arrow-body-style rule is triggered.
to:

         function removeEntity(res) {
             return function(entity) {
                 if(entity) {
                   return entity.remove()
                    .then(() => {
                            res.status(204).end();
------>                     return null;
                    });
                 }
             };
         }

Metadata

Metadata

Assignees

No one assigned

    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