Step: 1 What is an API?
Think of API as a postman who takes your letter to another person and gets back with a response.In simplest words, API is like a middle- man that helps client and server communicate with each other.
Step: 2 Call an AΡΙ
There are four steps to call an API:
1. Find an API
2. Request it
3. Handle response
4. Error handling
We will be using JavaScript to make the API call.
Step: 3
1. Find an API
We can use RapidAPI Hub, the home of over 35k+ APIs. I will use the Famous Quotes API from the Hub.
Step 4. Error handling
Lastly, let’s do some error handling in case the API request fails.
API Response
You will see a response like the following when you run your JavaScript file.