feat: simple api call to enable search

This commit is contained in:
Daniel Avila 2023-03-21 19:31:57 -04:00
parent 1041146fcb
commit 97a6cd801b
6 changed files with 50 additions and 38 deletions

View 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';
}
}