Assignment 1: HTTP Requests

This assignment gives you practice using HTTP requests to your local server. Feel free to use Postman or Insonmia to run these requests. Remember, Google is your friend! Since you're all starting to learn this infrastructure, rely on ChatGPT as little as possible so you actually remember how to do these things!

Now that you have your server running, you should see a landing page with a small library of books. Our task is to find a way to manage this library! We want to

  1. retrieve the list of books

  2. add a new book

  3. update an existing catalog entry

  4. remove a book

Which HTTP request corresponds to which action?

Your Task

Look through server.js. This should contain all the existing server code that exposes these possible actions to a user.

Additionally, to give you some more context, there's a database file that's cleared and repopulated every time the server restarts. If you restart the server, you will clear the database!

Based on the code in the file, please write the following:

  1. a request to get all the books

  2. add a new book to the library

  3. update the author of an existing book

  4. remove a book from the library

You may do this in several ways:

  • Postman/Insomnia provides a user-friendly way to make these requests. Feel free to search wherever to learn how to use these tools

  • Write Python, JavaScript, or any other code to make these requests. Postman also generates code for you, so you might find that feature helpful.

  • Write cURL requests. These are much harder for people to read but they work!

Some tips:

  • You may want to figure out what the data structure looks like for each database entry, or what data structure is used in general. Hint: they look pretty similar to Python dictionaries! Which fields are critical to operation?

  • Feel free to try as many things out as you want. Since everything is local to your computer and the database resets on server restart, nothing destructive will happen!

Changing code:

If you locate any errors, improvements, or code changes, please follow our workflow! Branch, modify your code, commit, then make a PR and one of the project leads will review it!

Last updated