You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scott Robertson edited this page Jan 21, 2021
·
1 revision
To use Tokenable via Axios, you could do something like this:
const{ data }=awaitaxios.post("https://example.com/api/auth",{email: "email@example.com",password: "coolpassword123",});consttoken=data.data.token;constuser_id=data.data.user_id;
You then use this token in all future API requests:
const{ data }=awaitaxios.get(`https://example.com/api/user/${user_id}`,{headers: {Authorization: `Bearer ${token}`},});