You can use any user's credentials from
dummyjson.com/users
fetch('https://dj.tdn.wf/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'kminchelle',
password: '0lelplR',
// expiresInMins: 60, // optional
})
})
.then(res => res.json())
.then(console.log);
Show output
{
"id": 15,
"username": "kminchelle",
"email": "kminchelle@qq.com",
"firstName": "Jeanne",
"lastName": "Halvorson",
"gender": "female",
"image": "https://robohash.org/Jeanne.png?set=set4",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTUsInVzZXJuYW1lIjoia21pbmNoZWxsZSIsImVtYWlsIjoia21pbmNoZWxsZUBxcS5jb20iLCJmaXJzdE5hbWUiOiJKZWFubmUiLCJsYXN0TmFtZSI6IkhhbHZvcnNvbiIsImdlbmRlciI6ImZlbWFsZSIsImltYWdlIjoiaHR0cHM6Ly9yb2JvaGFzaC5vcmcvYXV0cXVpYXV0LnBuZz9zaXplPTUweDUwJnNldD1zZXQxIiwiaWF0IjoxNjM1NzczOTYyLCJleHAiOjE2MzU3Nzc1NjJ9.n9PQX8w8ocKo0dMCw3g8bKhjB8Wo7f7IONFBDqfxKhs"
}
/* providing token in bearer */
fetch('https://dj.tdn.wf/auth/me', {
method: 'GET',
headers: {
'Authorization': 'Bearer /* YOUR_TOKEN_HERE */',
},
})
.then(res => res.json())
.then(console.log);
Show output
{
"id": 15,
"username": "kminchelle",
"email": "kminchelle@qq.com",
"firstName": "Jeanne",
"lastName": "Halvorson",
"gender": "female",
"image": "https://robohash.org/Jeanne.png?set=set4",
... // other user fields
}