- Notifications
You must be signed in to change notification settings - Fork15
coding-in-public/vanilla-javascript-challenges
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Here goes the short description of the challenge...
constBASEURL="https://dummyjson.com";
See API Documentation for help →https://dummyjson.com/docs/
use the/products
endpoint for (1 – 4)
- Create a fetch function called
customFetch
that hits the"https://dummyjson.com/products"
endpoint and console logs and returns the data. - Update the
customFetch
function to take in a endpoint and handle errors (including a wrong endpoint). - Create a function called
getProducts
that returns all the products in an array. Then list all the products in the DOM in an unordered list. - Update the
customFetch
function to handle a delete, add, or update a request.- Use the updated function to update and then delete a product by it’s ID. (FYI,
"https://dummyjson.com/products/1"
will access the product with the id of 1). - Use the updated function to POST a new product to the list of products. (FYI,
"https://dummyjson.com/products/add"
will allow POST requests).
- Use the updated function to update and then delete a product by it’s ID. (FYI,
use the/users
,/posts/
, and/comments
endpoints for (5 – 7)
- Create a function called
getFilteredUsers
that console logs and returns all the users who are 21 years old in a new array of objects in the following structure:
[{name:"John Doe",(containingfirstandlastname)age:21,email:"email@email.com",}, ...]
See help documentation for help athttps://dummyjson.com/docs/users. You can use thecustomFetch
function you created earlier.
Alter the
getFilteredUsers
function to return all filtered users in an object with the id as the key and the user object as the value. (See help documentation for help athttps://dummyjson.com/docs/users)Create a new function called
getCommentsOnUsersPosts
that takes in a user id and returns all comments on any post by that user in an array of objects. Each object should contain two properties,postTitle
andcomments
. Comments should contain theuserID
of the commentor and thetext
. Bonus points for filtering out posts without comments. Sample below:
[{postTitle:"Post Title",comments:[{userId:1,text:"Comment Text"},{userId:2,text:"Comment Again"}]}, ...]
Seehttps://dummyjson.com/docs/users,https://dummyjson.com/docs/posts, andhttps://dummyjson.com/docs/comments for help.
About
Resources
Uh oh!
There was an error while loading.Please reload this page.