Using JavaScript how to connect to a web API endpoint for JSON data.

Using JavaScript how to connect to a web API endpoint for JSON data.

Using JavaScript how to connect to a web API endpoint for JSON data.

Get JSON data and dynamically generate page content with JavaScript.   When connecting to server endpoints, a vast amount of data can then be used with your web application, allowing users to get data coming from those endpoints.  

Web API’s (Application Programming Interfaces) that fetch data from a server and return the data as JSON are commonly used.  APIs can provide data for your web users.   There are several API’s that you can connect to, to practice making fetch requests.  Many do require oAuth or other authenticate in order to be able to request it from your application.  There are however some open APIs that allow you to connect to them with just the URL.  The endpoints for these APIs can and do change, the setup and output is determined by the server application that creates the response object.  Often the response is done as JSON which is a universally easy data structure for coding languages to parse.   Some endpoints will have the parameters in the GET request URI, these can then be updated by updating the URL path including the new parameters.   

Browsers load files via the HTTP or HTTPS protocol.  HTTP is a stateless protocol which means once the content is served it won’t remember anything about this request.  It simply returns the request content, including parameters that are requested at the time of the request.  Parameters can be included depending on if the server endpoint is able to receive them, by adding the parameters in the URL after the question mark.  ? = parameters in URL

Leave a Comment