fix: simplify promise chain
This commit is contained in:
parent
8fe9c2551a
commit
a28d7d1aab
2 changed files with 3 additions and 5 deletions
|
|
@ -88,7 +88,7 @@ function update (id, data, userToken, txId) {
|
||||||
' where id=$1 returning *'
|
' where id=$1 returning *'
|
||||||
|
|
||||||
return db.one(sql, [id])
|
return db.one(sql, [id])
|
||||||
.then(customerData => {
|
.then(customerData => {
|
||||||
return getEditedData(id)
|
return getEditedData(id)
|
||||||
.then(customerEditedData => selectLatestData(customerData, customerEditedData))
|
.then(customerEditedData => selectLatestData(customerData, customerEditedData))
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,8 @@ function addOrUpdateCustomer (req) {
|
||||||
|
|
||||||
return add(req.body)
|
return add(req.body)
|
||||||
})
|
})
|
||||||
.then(customer => {
|
.then(customer => Promise.all([getEditedData(customer.id), getCustomerById(customer.id)]))
|
||||||
return Promise.all([getEditedData(customer.id), getCustomerById(customer.id)])
|
.then(([customerEditedData, customerOriginalData]) => selectLatestData(customerOriginalData, customerEditedData))
|
||||||
.then(([customerEditedData, customerOriginalData]) => selectLatestData(customerOriginalData, customerEditedData))
|
|
||||||
})
|
|
||||||
.then(customer => {
|
.then(customer => {
|
||||||
// BACKWARDS_COMPATIBILITY 7.5
|
// BACKWARDS_COMPATIBILITY 7.5
|
||||||
// machines before 7.5 expect customer with sanctions result
|
// machines before 7.5 expect customer with sanctions result
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue