-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (26 loc) · 745 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// ✨ implement axiosWithAuth
import axios from "axios";
export const axiosWithAuth = () => {
const token = localStorage.getItem('token')
return axios.create({
baseURL:'http://localhost:9000/api',
headers:{
authorization:token
},
})
}
/* import React from "react";
import { Route, Navigate } from 'react-router-dom'
export const ProtectedRoute = props => {
const { children, ...rest } = props
return (
<Route {...rest} render={(props) =>{
if(localStorage.getItem('token')){
return children
}else{
return <Navigate to='/' replace={true} />
}
}}
/>
)
} */