From 903bce40c3b013ed2f2347c254ea184293b45b22 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Fri, 29 Mar 2019 23:39:24 -0400
Subject: [PATCH] move formData generating logic to api.service
---
src/components/importer/importer.js | 5 +----
src/services/api/api.service.js | 6 ++++--
.../backend_interactor_service.js | 2 +-
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/components/importer/importer.js b/src/components/importer/importer.js
index 8d6c8b3fc2..44d02c9335 100644
--- a/src/components/importer/importer.js
+++ b/src/components/importer/importer.js
@@ -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
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 6b255e9f49..3f6ffccce4 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -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)
})
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index 75bba92ba0..2438c60344 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -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})