Search⌘ K

Solution: Understanding HTTP, REST, and APIs

Explore how to structure and manage API service files within a Git repository. Learn the process of creating a local Git repo, adding and committing files, and pushing the repository to GitHub for version control and collaboration.

Solution

The task in this exercise is to move the services folder (and all the API calls stored there) into the project repository we created earlier.

To keep things clear, we’ll start from the beginning by creating a new onboarding folder, making it a Git repository, and then copying the services folder into the repository and committing the changes.

Note: You can see the services folder’s content by executing the cd services and ls commands in the terminal provided below.

Here’s a step-by-step solution.

Creating local Git repository

First, create the onboarding project folder and change the directory to that new folder:

root@educative:/$ mkdir onboarding

root@educative:/$ cd onboarding

root@educative:/onboarding$

Next, make this new empty folder into a Git repository:

root@educative:/onboarding$ git init
Initialized empty Git repository in /home/mca/onboarding/.git/ 

root@educative:/onboarding$

Next, let’s add a README file to the repository. It’s always a good idea to use README files to help remember what’s in the ...