mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-26 05:08:50 +01:00
* create data-provider package and move code from data-provider folder to be shared between apps * fix type issues * add packages to ignore * add new data-provider package to apps * refactor: change client imports to use @librechat/data-provider package * include data-provider build script in frontend build * fix type issue after rebasing * delete admin/package.json from this branch * update test ci script to include building of data-provider package * Try using regular build for test action * Switch frontend-review back to build:ci * Remove loginRedirect from Login.tsx * Add ChatGPT back to EModelEndpoint
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import axios, { AxiosRequestConfig } from 'axios';
|
|
|
|
async function _get<T>(url: string, options?: AxiosRequestConfig): Promise<T> {
|
|
const response = await axios.get(url, { ...options });
|
|
return response.data;
|
|
}
|
|
|
|
async function _post(url: string, data?: any) {
|
|
const response = await axios.post(url, JSON.stringify(data), {
|
|
headers: { 'Content-Type': 'application/json' }
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
async function _postMultiPart(url: string, formData: FormData, options?: AxiosRequestConfig) {
|
|
const response = await axios.post(url, formData, {
|
|
...options,
|
|
headers: { 'Content-Type': 'multipart/form-data' }
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
async function _put(url: string, data?: any) {
|
|
const response = await axios.put(url, JSON.stringify(data), {
|
|
headers: { 'Content-Type': 'application/json' }
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
async function _delete<T>(url: string): Promise<T> {
|
|
const response = await axios.delete(url);
|
|
return response.data;
|
|
}
|
|
|
|
async function _deleteWithOptions<T>(url: string, options?: AxiosRequestConfig): Promise<T> {
|
|
const response = await axios.delete(url, { ...options });
|
|
return response.data;
|
|
}
|
|
|
|
async function _patch(url: string, data?: any) {
|
|
const response = await axios.patch(url, JSON.stringify(data), {
|
|
headers: { 'Content-Type': 'application/json' }
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
export default {
|
|
get: _get,
|
|
post: _post,
|
|
postMultiPart: _postMultiPart,
|
|
put: _put,
|
|
delete: _delete,
|
|
deleteWithOptions: _deleteWithOptions,
|
|
patch: _patch
|
|
};
|