feat: add axios instance
This commit is contained in:
parent
e0dca78ef3
commit
34be97996e
30
client/src/api/api.ts
Normal file
30
client/src/api/api.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import axios from 'axios';
|
||||
import { Access, Auth } from '../types/auth';
|
||||
|
||||
const baseURL = `${process.env.REACT_APP_HTTP_PROTOCOL}://${process.env.REACT_APP_API_URL}/api/v1`;
|
||||
|
||||
const base = axios.create({
|
||||
baseURL,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
accepts: 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
// base.interceptors.request.use((config) => {
|
||||
// const token = localStorage.getItem('accessToken');
|
||||
// if (token) {
|
||||
// config.headers.Authorization = `Bearer ${token}`;
|
||||
// }
|
||||
// return config;
|
||||
// });
|
||||
|
||||
const api = {
|
||||
async login(auth: Auth): Promise<Access> {
|
||||
console.log(auth);
|
||||
const response = await base.post<Access>('/auth', auth);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
export default api;
|
Loading…
Reference in New Issue
Block a user