不知道如何 return sth in a then of a promise

Don't know how to return sth in a then of a promise

我正在使用 firebase,我正在使用一些 promises(在本机反应应用程序中)。

我正在尝试部署,但 ESLINT 抱怨我的 then 子句没有 return 任何东西:

admin.auth().getUser(phone)
    .then(userRecord => {
      const code = Math.floor((Math.random() * 8999 + 1000))

      twilio.messages.create({
        body: 'Your code is ' + code,
        to: phone,
        from: '+4915735984308'
      }, (err) => {
        if (err) { return res.status(422).send(err) }

        admin.database().ref('users/' + phone)
          .update({code: code, codeValid: true}, () => {
            res.send({success: true})
          })
      })
    })
    .catch((err) => {
      res.status(422).send({error: err})
    })

问题是,我不想return任何东西,只是在数据库里写东西。我尝试了以下但没有成功:

.then(userRecord => {
      const code = Math.floor((Math.random() * 8999 + 1000))

      twilio.messages.create({
        body: 'Your code is ' + code,
        to: phone,
        from: '+4915735984308'
      }, (err) => {
        if (err) { return res.status(422).send(err) }

        admin.database().ref('users/' + phone)
          .update({code: code, codeValid: true}, () => {
            res.send({success: true}, () => {return true})
          })
      }, () => {return true})
    })
    .catch((err) => {
      res.status(422).send({error: err}, () => {return true})
    })

有人可以帮我解决这个问题吗?我应该在哪里写 return 语句?

只需尝试返回最后一行

admin.auth().getUser(phone)
    .then(userRecord => {
      const code = Math.floor((Math.random() * 8999 + 1000))

      return twilio.messages.create({
        body: 'Your code is ' + code,
        to: phone,
        from: '+4915735984308'
      }, (err) => {
        if (err) { return res.status(422).send(err) }

        admin.database().ref('users/' + phone)
          .update({code: code, codeValid: true}, () => {
            res.send({success: true})
          })
      })
    })
    .catch((err) => {
      res.status(422).send({error: err})
    })