Docs
You can use examples below to check how DummyJSON works.
Auth
Login user and get token
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
Get current auth user
/* 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