What's the best way to do authentication in modern applications
stringify ({ email, password }), }); const { token } = await res.
setItem ( 'token' , token); } async function fetchProfile () { const res = await fetch ( '/api/me' , { headers: { Authorization: `Bearer ${ localStorage .
let accessToken : string | null = null ; async function login ( email : string , password : string ) { const res = await fetch ( '/api/login' , { method: 'POST' , headers: { 'Content-Type' : 'application/json' }, body: JSON .
stringify ({ email, password }), }); const { token } = await res.
then (( res ) => { // Refresh itself can fail: the refresh token expired, or the rotation // detected reuse and burned the chain.
1 час назад @ neciudan.dev
infomate