From fba41717ad2d9b964cdc02963b87560f568093da Mon Sep 17 00:00:00 2001 From: Niel Rohling Date: Thu, 18 Apr 2019 01:07:08 +0200 Subject: [PATCH] service to fetch all --- src/services/ApiService.ts | 11 +++++++++++ src/services/ChannelService.ts | 9 --------- 2 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 src/services/ApiService.ts delete mode 100644 src/services/ChannelService.ts diff --git a/src/services/ApiService.ts b/src/services/ApiService.ts new file mode 100644 index 0000000..0844dd3 --- /dev/null +++ b/src/services/ApiService.ts @@ -0,0 +1,11 @@ +const API_URL = 'https://ts.cliffbreak.de/v1/'; + +export default class ApiService { + public static async fetchAllChannels() { + const channelRes = await fetch(API_URL + 'channels'); + const clientRes = await fetch(API_URL + 'clients'); + const channelJson = await channelRes.json(); + const clientJson = await clientRes.json(); + return { channelJson, clientJson }; + } +} diff --git a/src/services/ChannelService.ts b/src/services/ChannelService.ts deleted file mode 100644 index a1681f6..0000000 --- a/src/services/ChannelService.ts +++ /dev/null @@ -1,9 +0,0 @@ -const API_URL = 'https://ts.cliffbreak.de/v1/channels'; - -export default class ChannelService { - public static async fetchAllChannels() { - const response = await fetch(API_URL); - const json = await response.json(); - return json; - } -}