Conditional Routing - Async
Clash Royale CLAN TAG #URR8PPP Conditional Routing - Async I wanted to make a GET request to my server to verify if the user is authenticated or not, basically a true or false function. but it ended up being more complicated than that. GET true or false as i need an async , await function in order to get the response from the request i made. SO, thats what i did. but after calling the function inside a regular sync function which is PrivateRoute it only logs that the promise is still pending . async await response request sync PrivateRoute promise pending SO, i tried turning PrivateRoute into an async function. but react refused to render a [object promise] . PrivateRoute async [object promise] ANY IDEA what to do? const isAuthenticated = async () => { try{ let isAuth = await axios.get('/auth') console.log(isAuth.data) if(Object.keys(isAuth.data).length > 0) return true else return false } catch(err) { console.log(err) } } con...