The goal of this project is to provide a rough example of how to start building your own API. To align with Code:You's Web Development Capstone requirements, we will cover the following topics:
- Create a route to return:
- all data and a specific entry in the data by their id
- post data to the API
- Persist the data by reading and writing to a JSON file
- Create a form on the front-end to send POST requests to the API
The code for each lesson exists as its own branch. These branches will contain the solution to that lesson to compare your code against. You can access the lesson pdfs in the lessons directory
If you intend to fork this repository and clone it down to experiment with, keep in mind that you will need to switch to the branch that you want to view as the main branch will be the branch you will default to.
To switch to a branch, run:
git switch <branch-name>
Required Tools
- VS Code
- NodeJS
- npm
In GitBash:
- Verify NodeJS and npm are installed on your machine by running
node -vandnpm -v. If a version number is returned for each command, these have been successfully installed. cdinto yourprojectsdirectory and rungit clone https://github.com/CodeYouOrg/a-simple-api.gitcdinto the cloned repo and runnpm installto install the required packages.- Open the project with
code . - Run the server with
npm run dev
Switch to the desired branch using:
git switch <branch-name>