Google Cloud Functions - warning Avoid nesting promises promise/no-nesting

Solution 1:

You have a promise then() call nested inside another promise's then(). This is considered to be poor style, and makes your code difficult to read. If you have a sequence of work to perform, it's better to chain your work one after another rather than nest one inside another. So, instead of nesting like this:

doSomeWork()
.then(results1 => {
    return doMoreWork()
    .then(results2 => {
        return doFinalWork()
    })
})

Sequence the work like this:

doSomeWork()
.then(results => {
    return doMoreWork()
})
.then(results => {
    return doFinalWork()
})

Searching that error message also yields this helpful discussion.