Is there a way to simplify the code in this service method for updating an account on an API? I want to reduce the number of objects within the if conditions.
async updateAccount(uuid: string, body: IUpdateAccountDto) {
const found = await this.getAccountById(uuid);
const update = (resolve, reject) => {
if (
found.username ||
found.password ||
found.email ||
found.phone ||
found.product
) {
resolve(
'account updated',
((found.username = body.username),
(found.password = body.password),
(found.email = body.email),
(found.phone = body.phone),
(found.product = body.product)),
);
} else {
reject('cannot update username');
}
};
const updateAccount = new Promise(update);
return updateAccount;
}