Skip to content

Instantly share code, notes, and snippets.

@stephandesouza
Created June 20, 2018 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephandesouza/b7722252419f44b72bad86f6225945e6 to your computer and use it in GitHub Desktop.
Save stephandesouza/b7722252419f44b72bad86f6225945e6 to your computer and use it in GitHub Desktop.
vue-mc upload
upload() {
let data = new FormData();
forEach(this.getSaveData(), function(value, key) {
data.append(key, value);
});
let method = 'POST',
route = this.id ? this.getRoute('patch') : this.getRoute('create'),
url = this.getURL(route, this.getRouteParameters()),
config = function config() {
return {
url: url,
method: method,
data: data,
};
};
return this.request(config, this.onSave, this.onSaveSuccess, this.onSaveFailure);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment