From 0c3a922341a6f04f203396fb1c932411f6df0cd5 Mon Sep 17 00:00:00 2001 From: Brenden Bice Date: Tue, 2 Apr 2019 12:01:48 -0400 Subject: [PATCH] use promisedRequest for api call --- src/services/api/api.service.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 120398f0..1f9e9a88 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -725,29 +725,11 @@ const markNotificationsAsSeen = ({id, credentials}) => { } const fetchFavouritedByUsers = ({id}) => { - return fetch(MASTODON_STATUS_FAVOURITEDBY_URL(id), { - method: 'GET' - }) - .then(response => { - if (response.ok) { - return response.json() - } else { - throw new Error('Error fetching favorited by users') - } - }) + return promisedRequest(MASTODON_STATUS_FAVOURITEDBY_URL(id)).then((users) => users.map(parseUser)) } const fetchRebloggedByUsers = ({id}) => { - return fetch(MASTODON_STATUS_REBLOGGEDBY_URL(id), { - method: 'GET' - }) - .then(response => { - if (response.ok) { - return response.json() - } else { - throw new Error('Error reblogged by users') - } - }) + return promisedRequest(MASTODON_STATUS_REBLOGGEDBY_URL(id)).then((users) => users.map(parseUser)) } const apiService = {