Question: Need help with these javascript functions. user data format. { id: 1, name: Leanne Graham, username: Bret, email: Sincere@april.biz, address: { street: Kulas Light, suite:
Need help with these javascript functions. user data format. { "id": 1, "name": "Leanne Graham", "username": "Bret", "email": "Sincere@april.biz", "address": { "street": "Kulas Light", "suite": "Apt. 556", "city": "Gwenborough", "zipcode": "92998-3874", "geo": { "lat": "-37.3159", "lng": "81.1496" } }, "phone": "1-770-736-8031 x56442", "website": "hildegard.org", "company": { "name": "Romaguera-Crona", "catchPhrase": "Multi-layered client-server neural-net", "bs": "harness real-time e-markets" } }, getUser a. Receives a user id as a parameter b. Fetches data for a specific user id c. Should be an async function d. Should utilize a try / catch block e. Uses the fetch API to request a specific user id f. Await the user data response g. Return the JSON data getUserPosts a. Receives a user id as a parameter b. Fetches post data for a specific user id c. Should be an async function d. Should utilize a try / catch block e. Uses the fetch API to request all posts for a specific user id f. Await the users data response g. Return the JSON data . getUser a. Receives a user id as a parameter b. Fetches data for a specific user id c. Should be an async function d. Should utilize a try / catch block e. Uses the fetch API to request a specific user id f. Await the user data response getPostComments a. Receives a post id as a parameter b. Fetches comments for a specific post id c. Should be an async function d. Should utilize a try / catch block e. Uses the fetch API to request all comments for a specific post id f. Await the users data response g. Return the JSON data displayComments a. Dependencies: getPostComments, createComments b. Is an async function c. Receives a postId as a parameter d. Creates a section element with document.createElement() e. Sets an attribute on the section element with section.dataset.postId f. Adds the classes 'comments' and 'hide' to the section element g. Creates a variable comments equal to the result of await getPostComments(postId); h. Creates a variable named fragment equal to createComments(comments) i. Append the fragment to the section j. Return the section element createPosts a. Dependencies: createElemWithText, getUser, displayComments b. Is an async function c. Receives posts JSON data as a parameter d. Create a fragment element with document.createDocumentFragment() e. Loops through the posts data f. For each post do the following: g. Create an article element with document.createElement() h. Create an h2 element with the post title i. Create an p element with the post body j. Create another p element with text of `Post ID: ${post.id}` k. Define an author variable equal to the result of await getUser(post.userId) l. Create another p element with text of `Author: ${author.name} with ${author.company.name}` m. Create another p element with the authors company catch phrase. n. Create a button with the text 'Show Comments' o. Set an attribute on the button with button.dataset.postId = post.id p. Append the h2, paragraphs, button, and section elements you have created to the article element. q. Create a variable named section equal to the result of await displayComments(post.id); r. Append the section element to the article element s. After the loop completes, append the article element to the fragment t. Return the fragment element
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
