mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-07 19:18:52 +01:00
feat: simple api call to enable search
This commit is contained in:
parent
1041146fcb
commit
97a6cd801b
6 changed files with 50 additions and 38 deletions
23
client/src/utils/userAuth.js
Normal file
23
client/src/utils/userAuth.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export default async function fetchData() {
|
||||
try {
|
||||
const response = await axios.get('/api/me', {
|
||||
timeout: 1000,
|
||||
withCredentials: true
|
||||
});
|
||||
const user = response.data;
|
||||
if (user) {
|
||||
// dispatch(setUser(user));
|
||||
// callback(user);
|
||||
return user;
|
||||
} else {
|
||||
console.log('Not login!');
|
||||
window.location.href = '/auth/login';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.log('Not login!');
|
||||
window.location.href = '/auth/login';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue