Skip to content

Instantly share code, notes, and snippets.

@lucatsf
Created March 16, 2022 17:53
Show Gist options
  • Save lucatsf/b8dd514c524bed635ebd2c206999ebc1 to your computer and use it in GitHub Desktop.
Save lucatsf/b8dd514c524bed635ebd2c206999ebc1 to your computer and use it in GitHub Desktop.
Obtem retorno dinamico
//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