I am currently facing an issue in my vue.js application where I am struggling to access the value of name
that is being passed to my function. My hunch is that this issue is related to scope. After some research, it seems like using a fat arrow function might help resolve this problem?
Below is the code snippet I am using to handle a change event. Is there a way to
async handleChange(event, name) {
console.log('name: ', name); // works
console.log('value: ', event.value); // works
try {
let response = await axios.patch(`/my/path`, {
name: event.value, // need to extract the value from 'name'
});
if (response.status === 200) {
//
} else {
console.error('Error: could not update. ', response);
}
} catch (error) {
console.error('Error: sending patch request. ', error);
}
}
I have also attempted to refactor it like so:
handleChange: async (event, name) => {
...
}
I am uncertain about how to integrate a fat arrow function within the axios patch. Any guidance would be greatly appreciated. Thank you!