move formData generating logic to api.service

This commit is contained in:
taehoon 2019-03-29 23:39:24 -04:00
parent 562120ae48
commit 903bce40c3
3 changed files with 6 additions and 7 deletions

View File

@ -13,10 +13,7 @@ const Importer = {
},
submit () {
this.uploading = true
// eslint-disable-next-line no-undef
const formData = new FormData()
formData.append('list', this.file)
this.$store.state.api.backendInteractor.followImport({params: formData})
this.$store.state.api.backendInteractor.followImport(this.file)
.then((status) => {
if (status) {
this.success = true

View File

@ -634,9 +634,11 @@ const uploadMedia = ({formData, credentials}) => {
.then((data) => parseAttachment(data))
}
const followImport = ({params, credentials}) => {
const followImport = ({file, credentials}) => {
const formData = new FormData()
formData.append('list', file)
return fetch(FOLLOW_IMPORT_URL, {
body: params,
body: formData,
method: 'POST',
headers: authHeaders(credentials)
})

View File

@ -107,7 +107,7 @@ const backendInteractorService = (credentials) => {
const updateProfile = ({params}) => apiService.updateProfile({credentials, params})
const externalProfile = (profileUrl) => apiService.externalProfile({profileUrl, credentials})
const followImport = ({params}) => apiService.followImport({params, credentials})
const followImport = (file) => apiService.followImport({file, credentials})
const deleteAccount = ({password}) => apiService.deleteAccount({credentials, password})
const changePassword = ({password, newPassword, newPasswordConfirmation}) => apiService.changePassword({credentials, password, newPassword, newPasswordConfirmation})