AJAX endpoint connection for practice exploring the GitHub open API and get JSON data.
There are several open APIs endpoints that can be used to connect and retrieve data from. Testing these can be an excellent source for practice when connecting to large data JSON files. The navigation and selection of data that is deep within several levels of objects and arrays can be done piece by piece. Output the objects and arrays, then select the properties and values that you want to use in your code.
Connecting to external APIs that are open is not suggested for web development on live sites. These tend to change endpoints and once you build your connection your web page will be dependent on the connection access. There are many APIs that can be connected to the have authentication. For server side coding the API endpoints can be rendered by any backend code. The backend code would be outputting the JSON data and creating the dynamic outputs. Many endpoints are based on data coming from databases, the database connections and outputs are coded with the backend code. The server code will also control header access, so if you encounter an error this is one of the possible reasons.
Within the document object you can also create page elements as objects, this is an alternative to using the static innerHTML and then creating the elements with the HTML code. document.createElement(‘button’) will create a button, which can then be updated. Since this is already an object, properties like the event listeners can be added to it. Once the element is created it needs to be added to the web page, to a parent element. This can be done with append() or prepend().