I am using Dropzone.js with Vuejs2. The file upload is working fine however, inside the success
callback function i cannot assign the response to an object of the parent.
Here is a sample of my implementation:
<script>
import vueDropzone from "vue2-dropzone";
export default {
components: {
vueDropzone
},
props: {
},
data: () => ({
data: {
name: ''
},
dropOptions: {
url: "https://httpbin.org/post",
maxFileSize: 10,
autoProcessQueue: false,
success: (file, response) => {
if (response.message == "success"){
this.data.name = response.name;
this.add();
}
else{
console.log('Error Uploading file');
}
}
}),
};
</script>
the error is:
Uncaught TypeError: Cannot set property 'name' of undefined
I tried the solutions found Here but its still not working.