viral-vector / vue-upload-image

Configurable image uploader with preview
MIT License
34 stars 17 forks source link

Hook into http request #2

Closed MartinMuzatko closed 6 years ago

MartinMuzatko commented 6 years ago

hey there! For me, setting URL and formdata name for the image is not enough. I want to send additional formdata, POST and PUT requests and add my own headers.

Is there a way to hoop into the request before it is sent? Thanks!

viral-vector commented 6 years ago

Have gander at request interceptors. **using Axios as a provider.

// Add a request interceptor
vue.$http.interceptors.request.use((config) => {
   // do extra stuff here
  return config;
}, (error) => {
  return Promise.reject(error.response);
});

// Add a response interceptor
vue.$http.interceptors.response.use((response) => {
  // do extra stuff here
  return response;
}, (error) => {

  return Promise.reject(error.response);
});
viral-vector commented 6 years ago

Closing issue as this is not really an issue and inactivity.