From 5900bccff3f09be6bfbfa4a891c91ee043e3a9f0 Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Thu, 2 Aug 2018 18:34:12 +0900 Subject: [PATCH] debug --- .../who_to_follow_panel.js | 19 +++++++------------ src/services/api/api.service.js | 10 +++++++++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js index be9a9f31..5e85b95d 100644 --- a/src/components/who_to_follow_panel/who_to_follow_panel.js +++ b/src/components/who_to_follow_panel/who_to_follow_panel.js @@ -1,4 +1,6 @@ -function showWhoToFollow (panel, reply, aHost, aUser) { +import apiService from '../../services/api/api.service.js' + +function showWhoToFollow (panel, reply) { var users = reply.ids var cn var index = 0 @@ -58,17 +60,10 @@ function getWhoToFollow (panel) { panel.name2 = 'Loading...' panel.name3 = 'Loading...' var url = '/api/v1/suggestions' - window.fetch(url, {headers: authHeaders(credentials)}).then(function (response) { - if (response.ok) { - return response.json() - } else { - panel.name1 = '' - panel.name2 = '' - panel.name3 = '' - } - }).then(function (reply) { - showWhoToFollow(panel, reply, host, user) - }) + apiService.suggestions ({credentials: credentials}) + .then ((reply) => { + showWhoToFollow(panel, reply) + }) } } diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index adf598b7..d07e43c6 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -36,6 +36,7 @@ const CHANGE_PASSWORD_URL = '/api/pleroma/change_password' const FOLLOW_REQUESTS_URL = '/api/pleroma/friend_requests' const APPROVE_USER_URL = '/api/pleroma/friendships/approve' const DENY_USER_URL = '/api/pleroma/friendships/deny' +const SUGGESTIONS_URL = '/api/v1/suggestions' import { each, map } from 'lodash' import 'whatwg-fetch' @@ -448,6 +449,12 @@ const fetchMutes = ({credentials}) => { }).then((data) => data.json()) } +const suggestions = ({credentials}) => { + return fetch(SUGGESTIONS_URL, { + headers: authHeaders(credentials) + }).then((data) => data.json()) +} + const apiService = { verifyCredentials, fetchTimeline, @@ -481,7 +488,8 @@ const apiService = { changePassword, fetchFollowRequests, approveUser, - denyUser + denyUser, + suggestions } export default apiService