useSWR
This commit is contained in:
@ -1,29 +1,25 @@
|
||||
import React, { useContext } from 'react'
|
||||
import './Header.css';
|
||||
import '../App.css';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {Axios} from '../services/PhpApi'
|
||||
import {Axios, logOut, sleep} from '../services/PhpApi'
|
||||
import { toast, Toaster } from 'react-hot-toast';
|
||||
|
||||
|
||||
function Header() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const logOut = () =>
|
||||
function Header()
|
||||
{
|
||||
const logOutForm = () =>
|
||||
{
|
||||
Axios.post('logout.php')
|
||||
.then((res) =>
|
||||
{
|
||||
console.log(res);
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
|
||||
navigate('/'); // login
|
||||
}
|
||||
logOut();
|
||||
toast.success("logged out!");
|
||||
|
||||
sleep(1000);
|
||||
window.location.href = '/dog/';
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='logout'>
|
||||
<Toaster toastOptions={{ position: "top-center" }} />
|
||||
<div className='noprint'>Header</div>
|
||||
<button onClick={logOut}>Logout</button>
|
||||
<button onClick={logOutForm}>Logout</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user