add missing lib for mobile,
This commit is contained in:
84
03_source/mobile/src/lib/axios.ts
Normal file
84
03_source/mobile/src/lib/axios.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import type { AxiosRequestConfig } from 'axios';
|
||||
import axios from 'axios';
|
||||
import { CONFIG } from '../global-config';
|
||||
// import { CONFIG } from 'src/global-config';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const axiosInstance = axios.create({ baseURL: CONFIG.serverUrl });
|
||||
|
||||
axiosInstance.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => Promise.reject((error.response && error.response.data) || 'Something went wrong!')
|
||||
);
|
||||
|
||||
export default axiosInstance;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const fetcher = async (args: string | [string, AxiosRequestConfig]) => {
|
||||
try {
|
||||
const [url, config] = Array.isArray(args) ? args : [args];
|
||||
|
||||
const res = await axiosInstance.get(url, { ...config });
|
||||
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const endpoints = {
|
||||
chat: '/api/chat',
|
||||
kanban: '/api/kanban',
|
||||
calendar: '/api/calendar',
|
||||
auth: {
|
||||
me: '/api/auth/me',
|
||||
signIn: 'http://localhost:7272/api/auth/sign-in',
|
||||
signUp: '/api/auth/sign-up',
|
||||
},
|
||||
mail: {
|
||||
list: '/api/mail/list',
|
||||
details: '/api/mail/details',
|
||||
labels: '/api/mail/labels',
|
||||
},
|
||||
post: {
|
||||
list: '/api/post/list',
|
||||
details: '/api/post/details',
|
||||
latest: '/api/post/latest',
|
||||
search: '/api/post/search',
|
||||
},
|
||||
product: {
|
||||
list: '/api/product/list',
|
||||
details: '/api/product/details',
|
||||
search: '/api/product/search',
|
||||
},
|
||||
user: {
|
||||
list: '/api/user/list',
|
||||
profile: '/api/user/profile',
|
||||
update: '/api/user/update',
|
||||
settings: '/api/user/settings',
|
||||
details: '/api/user/details',
|
||||
},
|
||||
order: {
|
||||
list: '/api/order/list',
|
||||
profile: '/api/order/profile',
|
||||
update: '/api/order/update',
|
||||
settings: '/api/order/settings',
|
||||
details: '/api/order/details',
|
||||
changeStatus: (orderId: string) => `/api/order/changeStatus?orderId=${orderId}`,
|
||||
},
|
||||
invoice: {
|
||||
list: '/api/invoice/list',
|
||||
profile: '/api/invoice/profile',
|
||||
update: '/api/invoice/update',
|
||||
saveInvoice: (invoiceId: string) => `/api/invoice/saveInvoice?invoiceId=${invoiceId}`,
|
||||
settings: '/api/invoice/settings',
|
||||
details: '/api/invoice/details',
|
||||
changeStatus: (invoiceId: string) => `/api/invoice/changeStatus?invoiceId=${invoiceId}`,
|
||||
search: '/api/invoice/search',
|
||||
},
|
||||
};
|
Reference in New Issue
Block a user