aboutsummaryrefslogtreecommitdiffstats
path: root/helpers/logout.js
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/logout.js')
-rw-r--r--helpers/logout.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/helpers/logout.js b/helpers/logout.js
new file mode 100644
index 0000000..f530e8c
--- /dev/null
+++ b/helpers/logout.js
@@ -0,0 +1,12 @@
+import fetchJson from 'helpers/fetchJson'
+
+const handleLogout = async (e, router, mutateUser) => {
+ e.preventDefault()
+ mutateUser(
+ await fetchJson('/api/logout', { method: 'POST' }),
+ false
+ )
+ router.push('/login')
+}
+
+export default handleLogout