diff options
Diffstat (limited to 'src/requests.ts')
-rw-r--r-- | src/requests.ts | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/requests.ts b/src/requests.ts index 486502d..6446baa 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -1,10 +1,12 @@ -import axios, { AxiosResponse } from 'axios'; +import axios from 'axios'; -type Request = (url: string, data?: Record<string, unknown>) => Promise<AxiosResponse>; +const requests = axios.create({ + baseURL: 'http://localhost:3030', + headers: { + 'Authorization': localStorage.getItem('token') + } +}); -const baseApiUrl = 'http://localhost:3030'; - -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); +export const { get, post, put } = requests; +export default requests; |