抱歉,`.exec()`不知道如何处理{...}回调

时间:2019-01-10 18:25:09

标签: node.js angularjs sails.js

伙计们,我正在航行中,但遇到错误

-对不起,.exec()不知道如何处理{...}回调

我尝试卸载节点软件包,并使用npm install重新安装,但是没有运气。

请输入...。 这是我的用法。

这是我执行主要逻辑的用户控制器


module.exports = {
    // Sign User Up
    signup: function (req, res) {
        console.log('Backend Signup');
        var Passwords = require('machinepack-passwords');

        //Encrypt Password
        Passwords.encryptPassword({
            password: req.param('password'),
            difficulty: 10,
        }).exec({
            error: function (err) {
                return res.negotiate(err);
            },
            success: function (encryptedPassword) {
                console.log(req.params);
                require('machinepack-gravatar').getImageUrl({
                    emailAddress: req.param('email')
                }).exec({
                    error: function (err) {
                        return res.negotiate(err);
                    },
                    success: function (gravatarUrl) {
                        // Create User
                        User.create({
                            name: req.param('name'),
                            email: req.param('email'),
                            password: encryptedPassword,
                            lastLoggedIn: new Date(),
                            gravatarUrl: gravatarUrl
                        }, function userCreated(err, newUser) {
                            if (err) {
                                console.log('Error: ' + err);
                                return res.negotiate(err);
                            }

                            // Session Var
                            console.log('User Added');
                            return res.json({
                                id: newUser.id
                            });
                        })
                    }
                })
            }
        })
    },

package.json

    {
  "name": "rohi-sail",
  "private": true,
  "version": "0.0.0",
  "description": "a Sails application",
  "keywords": [],
  "dependencies": {
    "@sailshq/connect-redis": "^3.2.1",
    "@sailshq/lodash": "^3.10.3",
    "@sailshq/socket.io-redis": "^5.2.0",
    "grunt": "1.0.1",
    "machinepack-gravatar": "^2.0.0",
    "machinepack-passwords": "^2.3.0",
    "sails": "^1.0.2",
    "sails-hook-grunt": "^3.1.0",
    "sails-hook-orm": "^2.1.1",
    "sails-hook-sockets": "^1.5.5"
  },
  "devDependencies": {
    "@sailshq/eslint": "^4.19.3"
  },
  "scripts": {
    "start": "NODE_ENV=production node app.js",
    "test": "npm run lint && npm run custom-tests && echo 'Done.'",
    "lint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔  Your .js files look good.'",
    "custom-tests": "echo \"(No other custom tests yet.)\" && echo"
  },
  "main": "app.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/anonymous node/sails user/rohi-sail.git"
  },
  "author": "anonymous node/sails user",
  "license": "",
  "engines": {
    "node": "^10.5"
  }
}

0 个答案:

没有答案