CSE 341: Web Services

W02 Learning Activity: HTTP Requests and API Documentation

Overview

Having mastered GET requests, you will now learn how to add POST, PUT, and DELETE requests to your API. You will also learn more about API Documentation. In addition, you will also learn several tools that will make your development more efficient and productive.

Topics for this lesson:

Resources

Resources for this lesson are accessible to you in this repository.

URI Hierarchies
POST

As you learn about these different HTTP methods, know that there are always other ways to do things. For example, MongoDB uses queries and functions to insert, update, delete and retrieve data. Technically, I could use a POST to get data, modify it, or even delete it. However, these HTTP methods are here to add clarity and consistency to applications, and will work with other databases that don't rely on functions as much as MongoDB does.

PUT
DELETE
MongoDB CRUD

Here is a great article that sums up the CRUD (Create, Read, Update, Delete) process using Node.js and MongoDB.

Linters

Once you learn how to use code linters, you should never go back. When properly configured, they help keep your code, neat, clean, functional, and error-free. You should use a linter on your code for the remainder of this class.

Code Formatters

Once you learn how to use code formatters, you should never go back. When properly configured, they help keep your code neat, consistent and clean. You should use a formatter on your code for the remainder of this class.

Project Configuration and Management

The following article shows how to set up a linter and formatter with your project. You may ignore the React parts at this point, and be sure to select Node instead of Browser when it prompts for where your code will run.

Once this is all set up, you can run commands from the terminal like: "npm run lint" or the others that we put into the package.json.

API Documentation
Swagger
Other Options?

Be aware that there are other resources for doing very similar types of API documentation. None of them appear to be as widely integrated with npm or as widely used in industry. Two other popular ones are Postman (which started off as just a rest client), and Readme. We will only use Swagger in this course.

Other Links: