I am trying to chain data from an API request together and would like to gather promises from two of the blocks into a third then
.
The pattern is as follows:
sql.connect(config.properties).then(pool => {
return pool.request()
.execute('stored_proc')
.then(response => { res.send(response) })
.catch(err => { res.send(err) })
.then((response, err) => { someFunction(response, err) }) // bundle here
.finally(() => sql.close())
})
How can I pass response
and err
into the second then
block to pass into a function?