Fetching only once

so i have an authToken being stored in the local storage and i want to send it in a POST request each time the user opens the site to check if its still valid, but how do i make the POST request only fire once when the website first loads, that way i know if the user is authenticated or not and dont have to fetch it again while they are using the app. Im using next 13 with the app dir
2 Replies
peterkyle01
peterkyle012y ago
useEffect with reg ex for holding every url path on your app in the array of dependencies,and clean it up after render
Grey
Grey2y ago
use a HTTP only cookie to store authtokens, that way they're always sent as a cookie in your http requests, plus no js can access those cookies other than that a simple useEffect can suffice
Want results from more Discord servers?
Add your server