diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-10 20:22:33 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-10 20:22:33 +0300 |
commit | b85725ec0fd5088a619a20d2a6370b1f4a38cc22 (patch) | |
tree | b94e8c0841521a50628574899f9a7ad5f5c7cf0c /src | |
parent | e92ebe01e3a33dcc75b5e5ffd8d29933a2cf17df (diff) | |
download | which-ui-b85725ec0fd5088a619a20d2a6370b1f4a38cc22.tar.gz |
refactor: add types to requests
Diffstat (limited to 'src')
-rw-r--r-- | src/requests.ts | 14 |
1 files changed, 6 insertions, 8 deletions
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<string, unknown>) => Promise<AxiosResponse>; -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); |