I might have two type of payloads.
const payload = {
"firstName":"Steven",
"lastName":"Smith"
}
or
const payload = {
"personalDetails": {
"firstName":"Steven",
"lastName":"Smith"
}
}
How can I retrieve firstName from the payload during a REST API call.
const { firstName } = payload;
The above code will work for the first payload but it won't for the second payload since firstName is nested inside personalDetails. Is there a clean of retrieving it in ES6?