Coder Social home page Coder Social logo

fetch_fluency_quiz1's Introduction

Code Fluency Quiz: Fetch API + Asynchronous HTTP Requests

Directions

For the following questions, use the JSON Placeholder API. Because we are testing in Node, we will be using the node-fetch module. This will allow us to use the window.fetch function in Node as we typically do in the browser. We import this module on line 1 of app.js.

Install necessary dependencies with npm install. Write your solutions to the problem below in app.js. Test your solutions with npm test.

  1. Write a function, getPost, that makes a GET request to the /posts route and returns a Promise that resolves to a parsed JSON object that corresponds to the user post with the given id:
getPost(2);
/* returns
{
  userId: 1,
  id: 2,
  title: "qui est esse",
  body: "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
}
*/
  1. Write a function, getUsers, that returns a Promise that resolves to an array of the first and last names of all ten users.

  2. Write a function, getAddresses, that returns a Promise that resolves to an array of all user addresses. Addresses should be formatted as comma separated strings containing the "street", "suite", and "city" in that order.

  3. Write a function, shortestPost, that returns a Promise that resolves to the user post object with the shortest body.

  4. This database has 200 todos. Write a function called numCompleted returns a Promise that resolves to the number of tasks that are marked complete.

  5. Write a function called searchPosts that takes a string argument (searchWord) and returns a Promise that resolves to an array containing all of the posts have the search word in the body of the post.

  6. In the index.html file, create a form with a text input and a submit button. When you submit a users name (first or last), the text input should clear and a table with the user's data should appear below the form. If no user is found, a message saying, "No User Found" should appear below the form.

fetch_fluency_quiz1's People

Contributors

rogbonna1 avatar thuyanduong avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.