Skip to content

Commit

Permalink
fix: trim JSON in form data
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed Oct 23, 2018
1 parent d54b4d2 commit b10d3eb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/MultipartForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ export default {
getFormData() {
const form = new FormData()
Object.keys(this.properties)
.filter(key => this.model[key] !== null)
.filter(key => !!this.model[key])
.forEach(key => {
form.append(key, this.model[key])
if (['object', 'array'].includes(this.properties[key].type)) {
if (this.model[key].trim() !== '') form.append(key, this.model[key].trim())
} else {
form.append(key, this.model[key])
}
})
return form
}
Expand Down

0 comments on commit b10d3eb

Please sign in to comment.