I am trying to remove the 'name' property from registerReqOptions in this code.
const registerReqOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: registerObj.name,
email: registerObj.email,
password: registerObj.password
})
}
I tried;
const {body: {name}, ...loginReqOptions} = registerReqOptions
but it is removing the whole 'body' property instead of only the nested 'name' one.
What is the correct way to do this using the newer spread and rest syntax?
Thanks.