Express服务器停止而不会抛出错误

时间:2015-12-27 04:18:19

标签: angularjs node.js express sequelize.js yeoman-generator-angular

我正在使用角度fullstack生成器,但我不相信这是问题所在。我正在使用Stripe.js并尝试使用Sequelize将数据保存到SQLite数据库。我尝试了很多不同的东西,但是当它到达应该保存数据的部分时服务器停止运行。



  app.post('/register', auth.isAuthenticated(), function(req,res){
    console.log('access: ',req.query)
    var userId = req.body._id
    var data = req.body.data
    //create stripe acct for artists
    stripe.accounts.create(data, function(err,acct){

      if(err){
        console.log('err!!! ', err)
      } else {
        console.log('acct: ', acct)
        //look for user in database
        db.User.find({
            where: {
              _id: userId
            }
          })
          .then(function(user) {
            if(user){
              console.log('user: ', user)
              //add stripe acct info to db
              console.log('acct:', user.dataValues.account);
            /*this is where the Server stops running*/
              user.updateAttributes({
                account: JSON.stringify(acct)
              }).success(function(){
                console.log('newacct:', user.dataValues.account);
                //just to see if it works
                res.send({'account': acct});

              })



            } else {
              console.log('no user found bruh')
            }
          });
        
      }

    })
  })




我尝试过重定向,将req.method改为' get'然后是res.redirect。 res.end()以上所有,但它总是停止运行。没有错误只是简单地说“停止Express Server'”。在此先感谢您的帮助!

0 个答案:

没有答案
相关问题