[Vuejs]-Why Axios in this code doesn’t send any data to the back-end in Vue?

0👍

Try out to restructure the request like :

            event.preventDefault();
            let formData = new FormData();
            formData.append("ImageData.File", this.selectedFile);

            let config = {
                headers: {
                    "Content-Type": "multipart/form-data"
                }
            };
            axios({
                baseURL: 'https://some-domain.com/api/', // your backend base url
                method: 'post',
                url:'/api/Image',
                data:formData,
                ...config

            }).then(resposne => resposne.json())

0👍

I was wrapping the formData and config in an object. They should be the second and third arguments passed to post, like this:

axios.post('/api/Image', formData, config)

And the problem is solved!

Leave a comment