Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
JoelParke opened this issue Dec 17, 2016 · 0 comments
Closed
1 task done

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

JoelParke opened this issue Dec 17, 2016 · 0 comments

Comments

@JoelParke
Copy link

JoelParke commented Dec 17, 2016

  • 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;
                    });
                 }
             };
         }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant