Reputation:
Why this code worked for me, i want to do a request
const ChangeSettings= (flag)=>{
await client.put(`${MyEndpoint}/${car}`, {
flag,
})
but when i copy in a new var, dont work
const ChangeSettings = (flag)=>{
let copyFlag=flag
await client.put(`${MyEndpoint}/${car}`, {
copyFlag,
})
what is the wrong?
Upvotes: 0
Views: 35
Reputation: 13692
flag is an object which has a key flag
and you are passing an object copyFlag
with a key copyFlag
. Hence the issue
Use this
const updateUserSettingsInfo = (flag)=>{
let copyFlag=flag
await client.put(`${MyEndpoint}/${car}`, {
flag: copyFlag, //<---- change the key of an object
})
side note - since you are awaiting in your function, make sure to use async
const updateUserSettingsInfo = async (flag) => {
...
Upvotes: 2