Hi everyone so I just wanted to know where I could find the file name in my object. I did a console.log to find the property but I was a little bit lost. I tried to do ${data.name} but it says undefined. Anyone know where can I find it in my request ?
//the function
async onUpload() {
const formData = new FormData();
formData.append('image', this.ModalFile, this.ModalFile.name);
await axios.post('/publications/uploads', formData, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `Bearer ${this.$store.state.token}`,
},
//router
router.post('/uploads', upload.single('image'), async (request, response) => {
const data = await request.files[0].buffer;
console.log(data);
await fs.writeFile(`./uploads/${data.name}`, data);
return response.status(200).json({ uploaded: true });
}); ```