Docs
You can use examples below to check how DummyJSON works.
Users
Get all users
Show outputfetch('https://dummyjson.com/users') .then(res => res.json()) .then(console.log);
Get current auth user
Show output/* providing token in bearer */ fetch('https://dummyjson.com/user/me', { method: 'GET', headers: { 'Authorization': 'Bearer /* YOUR_TOKEN_HERE */', }, }) .then(res => res.json()) .then(console.log);
Get a single user
Show outputfetch('https://dummyjson.com/users/1') .then(res => res.json()) .then(console.log);
Search users
Show outputfetch('https://dummyjson.com/users/search?q=John') .then(res => res.json()) .then(console.log);
Filter users
You can pass key (nested keys with ".") and value as params to
filter users. (key and value are case-sensitive)
"limit", "skip" and "select" works too.
Show outputfetch('https://dummyjson.com/users/filter?key=hair.color&value=Brown') .then(res => res.json()) .then(console.log);
Limit and skip users
You can pass "limit" and "skip" params to limit and skip the
results for pagination, and use limit=0 to get all items.
You can pass "select" as query params with comma-separated values
to select specific data.
Show outputfetch('https://dummyjson.com/users?limit=5&skip=10&select=firstName,age') .then(res => res.json()) .then(console.log);
Get user's carts by user id
Show output/* getting carts of user with id 5 */ fetch('https://dummyjson.com/users/5/carts') .then(res => res.json()) .then(console.log);
Get user's posts by user id
Show output/* getting posts of user with id 5 */ fetch('https://dummyjson.com/users/5/posts') .then(res => res.json()) .then(console.log);
Get user's todos by user id
Show output/* getting todos of user with id 5 */ fetch('https://dummyjson.com/users/5/todos') .then(res => res.json()) .then(console.log);
Add a new user
Adding a new user will not add it into the server.
It will simulate a POST request and will return the new created
user with a new id
Show outputfetch('https://dummyjson.com/users/add', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ firstName: 'Muhammad', lastName: 'Ovi', age: 250, /* other user data */ }) }) .then(res => res.json()) .then(console.log);
Update a user
Updating a user will not update it into the server.
It will simulate a PUT/PATCH request and will return the user with
modified data
Show output/* updating lastName of user with id 1 */ fetch('https://dummyjson.com/users/1', { method: 'PUT', /* or PATCH */ headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ lastName: 'Owais' }) }) .then(res => res.json()) .then(console.log);
Delete a user
Deleting a user will not delete it into the server.
It will simulate a DELETE request and will return deleted user
with "isDeleted" & "deletedOn" keys
Show outputfetch('https://dummyjson.com/users/1', { method: 'DELETE', }) .then(res => res.json()) .then(console.log);