From a28d7d1aabc751127d86e72fe9c654dd496d62b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Thu, 20 Jan 2022 12:34:22 +0000 Subject: [PATCH] fix: simplify promise chain --- lib/customers.js | 2 +- lib/routes/phoneCodeRoutes.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/customers.js b/lib/customers.js index 1ba9e8c0..1f15dc91 100644 --- a/lib/customers.js +++ b/lib/customers.js @@ -88,7 +88,7 @@ function update (id, data, userToken, txId) { ' where id=$1 returning *' return db.one(sql, [id]) - .then(customerData => { + .then(customerData => { return getEditedData(id) .then(customerEditedData => selectLatestData(customerData, customerEditedData)) }) diff --git a/lib/routes/phoneCodeRoutes.js b/lib/routes/phoneCodeRoutes.js index b14a946b..ac92531f 100644 --- a/lib/routes/phoneCodeRoutes.js +++ b/lib/routes/phoneCodeRoutes.js @@ -26,10 +26,8 @@ function addOrUpdateCustomer (req) { return add(req.body) }) - .then(customer => { - return Promise.all([getEditedData(customer.id), getCustomerById(customer.id)]) - .then(([customerEditedData, customerOriginalData]) => selectLatestData(customerOriginalData, customerEditedData)) - }) + .then(customer => Promise.all([getEditedData(customer.id), getCustomerById(customer.id)])) + .then(([customerEditedData, customerOriginalData]) => selectLatestData(customerOriginalData, customerEditedData)) .then(customer => { // BACKWARDS_COMPATIBILITY 7.5 // machines before 7.5 expect customer with sanctions result