Closed redxzeta closed 3 years ago
Maybe store it in localstorage or something so there won't be in constant requests in App.js?
App.js
Unless someone has a better solution
const [token, setToken] = useState(""); useEffect(() => { axios .post( "https://api.petfinder.com/v2/oauth2/token", `grant_type=client_credentials&client_id=${process.env.REACT_APP_PETFINDER_KEY}` ) .then((response) => { setToken(response.data.access_token); }) .catch((error) => { console.log(error); }); }, []);
Although redux + local storage would be the best solution, storing the token into the local storage will absolutely work in this case.
Maybe store it in localstorage or something so there won't be in constant requests in
App.js
?Unless someone has a better solution