Created
March 16, 2022 17:53
-
-
Save lucatsf/b8dd514c524bed635ebd2c206999ebc1 to your computer and use it in GitHub Desktop.
Obtem retorno dinamico
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Manual | |
const resultsA = { | |
name: request.name.value, | |
age: request.age.value, | |
description: request.description.value, | |
price: request.price.value, | |
image: request.image.value, | |
} | |
//Dinamico | |
const resultsB = Object | |
.keys(request) | |
.reduce((result, key) => { | |
result[key] = request[key].value | |
return result | |
}, {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment