Created
February 1, 2021 12:33
-
-
Save cihat/0b2b379a6c75f9f1920a068a01ac9c47 to your computer and use it in GitHub Desktop.
Making AJAX calls in pure JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getCountryData = country => { | |
| const request = new XMLHttpRequest(); | |
| request.open('GET', `https://restcountries.eu/rest/v2/name/${country}`); | |
| request.send(); | |
| request.addEventListener('load', function () { | |
| const [data] = JSON.parse(this.responseText); | |
| console.log(data); | |
| countriesContainer.insertAdjacentHTML('beforeend', html); | |
| countriesContainer.style.opacity = 1; | |
| }); | |
| getCountryData('türkiye'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment