mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-09 03:58:51 +01:00
chore: reorganize client files for docker
This commit is contained in:
parent
affbaaf1a5
commit
f5e079742a
93 changed files with 178726 additions and 1 deletions
30
client/src/utils/fetchers.js
Normal file
30
client/src/utils/fetchers.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
import axios from 'axios';
|
||||
import useSWR from 'swr';
|
||||
import useSWRMutation from 'swr/mutation';
|
||||
|
||||
const fetcher = (url) => fetch(url).then((res) => res.json());
|
||||
|
||||
const postRequest = async (url, { arg }) => {
|
||||
return await axios.post(url, { arg });
|
||||
};
|
||||
|
||||
export const swr = (path, successCallback) => {
|
||||
const options = {};
|
||||
|
||||
if (successCallback) {
|
||||
options.onSuccess = successCallback;
|
||||
}
|
||||
|
||||
return useSWR(path, fetcher, options);
|
||||
}
|
||||
|
||||
export default function manualSWR(path, type, successCallback) {
|
||||
const options = {};
|
||||
|
||||
if (successCallback) {
|
||||
options.onSuccess = successCallback;
|
||||
}
|
||||
const fetchFunction = type === 'get' ? fetcher : postRequest;
|
||||
return useSWRMutation(path, fetchFunction, options);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue