diff options
-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); |