Skip to main content

Posts

Showing posts with the label API's

API's Study Notes: How To Make API Request With Node?

The course shows us we can make API's requests with Node. The first thing we need to do is to create the "APIs" directory and touch "request.js" file inside that folder. Then, we need to npm install request package in the APIs directory. Once we have done those basic steps, we can start to require the "request" and make a request from a JavaScript file. In the request, we need to have the "url" , so the server knows where it should request the API. Next, we need to have a function. request("url", function(error, response, body) In the function, there are three things we pass in: error, response, and body . Error: it will hold any potential error that we get such as internet disconnect, 404, and etc. It is important to check for an error. Response : it will be the incoming message that we receive Body : it is the actual response body that came back like HTML code For example, in the "request.js" ...

Study Note For API's: These Two Main Data Formats You Should Know

What is API's? API's stands for application programming interface. They are interfaces for code or computers to talk to one another. For example, we can use a Facebook account to login to Instagram. When we connect these two apps, Instagrams will link to and access your Facebook data. When you upload photos on Instagram, it will be automatically uploaded on Facebook, too. We also use a lot of Web API's every day. Web API's generally to communicate via HTTP. For example, we may ask Yelp API's to recommend 10 nearby Sushi restaurants in a certain zip code. Data Formats There are two main formats that web API is responded with: XML and JSON . When we use the internet, we make an HTTP request and get HTML back. API's don't respond with HTML because HTML contains information about the structure of a page. API's respond with data, not structure. XML XML stands for Extended Markup Language. It is syntactically similar to HTML, but it...