Docs
You can use examples below to check how DummyJSON works.
Products
Get all products
Show outputfetch('https://dummyjson.com/products') .then(res => res.json()) .then(console.log);
Get a single product
Show outputfetch('https://dummyjson.com/products/1') .then(res => res.json()) .then(console.log);
Search products
Show outputfetch('https://dummyjson.com/products/search?q=phone') .then(res => res.json()) .then(console.log);
Limit and skip products
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/products?limit=10&skip=10&select=title,price') .then(res => res.json()) .then(console.log);
Get all products categories
Show outputfetch('https://dummyjson.com/products/categories') .then(res => res.json()) .then(console.log);
Get products of a category
Show outputfetch('https://dummyjson.com/products/category/smartphones') .then(res => res.json()) .then(console.log);
Add a new product
Adding a new product will not add it into the server.
It will simulate a POST request and will return the new created
product with a new id
Show outputfetch('https://dummyjson.com/products/add', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: 'BMW Pencil', /* other product data */ }) }) .then(res => res.json()) .then(console.log);
Update a product
Updating a product will not update it into the server.
It will simulate a PUT/PATCH request and will return the product
with modified data
Show output/* updating title of product with id 1 */ fetch('https://dummyjson.com/products/1', { method: 'PUT', /* or PATCH */ headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: 'iPhone Galaxy +1' }) }) .then(res => res.json()) .then(console.log);
Delete a product
Deleting a product will not delete it into the server.
It will simulate a DELETE request and will return deleted product
with "isDeleted" & "deletedOn" keys
Show outputfetch('https://dummyjson.com/products/1', { method: 'DELETE', }) .then(res => res.json()) .then(console.log);