From b85725ec0fd5088a619a20d2a6370b1f4a38cc22 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 10 Jun 2020 20:22:33 +0300 Subject: refactor: add types to requests --- src/requests.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/requests.ts b/src/requests.ts index c653073..486502d 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -1,12 +1,10 @@ -import axios from 'axios'; +import axios, { AxiosResponse } from 'axios'; -const baseApiUrl = 'http://localhost:3030'; +type Request = (url: string, data?: Record) => Promise; -export const get = (url: string) => { - return axios.get(baseApiUrl + url) -}; +const baseApiUrl = 'http://localhost:3030'; -export const post = (url: string, data: object) => { - return axios.post(baseApiUrl + url, data); -}; +export const get: Request = url => axios.get(baseApiUrl + url); +export const del: Request = url => axios.delete(baseApiUrl + url); +export const post: Request = (url, data) => axios.post(baseApiUrl + url, data); -- cgit v1.2.3