Object # has no method 'catch'

后端 未结 1 442
遇见更好的自我
遇见更好的自我 2020-12-04 00:03

My user lib have following code for register

function register {
// do some validation on lib level

//user is instance of user collection
user.save()
    .t         


        
相关标签:
1条回答
  • 2020-12-04 01:01

    It seems you're not using Bluebird, but mongoose promises (mpromise), which don't have a .catch method.

    You can fix that by

    • using user.saveAsync().then(…), as you've promisified the User model
    • using Promise.resolve(user.save()).then(…) to cast the mongoose promise into a Bluebird one
    0 讨论(0)
提交回复
热议问题