diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index cb0ad9f30a..a2a23c6fbe 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -238,9 +238,8 @@ const UserSettings = { exportFollows () { this.enableFollowsExport = false this.$store.state.api.backendInteractor - .fetchFriends({ - id: this.$store.state.users.currentUser.id, - isExport: true + .exportFriends({ + id: this.$store.state.users.currentUser.id }) .then((friendList) => { this.exportPeople(friendList, 'friends.csv') diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index df9205735c..24ff0f7433 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -247,14 +247,18 @@ const fetchUser = ({id, credentials}) => { .then((data) => parseUser(data)) } -const fetchFriends = ({id, page, isExport, credentials}) => { +const fetchFriends = ({id, page, credentials}) => { let url = `${FRIENDS_URL}?user_id=${id}` if (page) { url = url + `&page=${page}` } - if (isExport) { - url = url + `&export=${isExport}` - } + return fetch(url, { headers: authHeaders(credentials) }) + .then((data) => data.json()) + .then((data) => data.map(parseUser)) +} + +const exportFriends = ({id, credentials}) => { + let url = `${FRIENDS_URL}?user_id=${id}&export=true` return fetch(url, { headers: authHeaders(credentials) }) .then((data) => data.json()) .then((data) => data.map(parseUser)) @@ -539,6 +543,7 @@ const apiService = { fetchConversation, fetchStatus, fetchFriends, + exportFriends, fetchFollowers, followUser, unfollowUser, diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index 423aeba554..c2d1617e1f 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -14,6 +14,10 @@ const backendInteractorService = (credentials) => { return apiService.fetchFriends({id, page, isExport, credentials}) } + const exportFriends = ({id}) => { + return apiService.exportFriends({id, credentials}) + } + const fetchFollowers = ({id, page}) => { return apiService.fetchFollowers({id, page, credentials}) } @@ -78,6 +82,7 @@ const backendInteractorService = (credentials) => { fetchStatus, fetchConversation, fetchFriends, + exportFriends, fetchFollowers, followUser, unfollowUser,