Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nemethricsi/code-snippets

code snippets and more
https://github.com/nemethricsi/code-snippets

Last synced: about 3 hours ago
JSON representation

code snippets and more

Awesome Lists containing this project

README

        

## Function for GET `XMLHttpRequest`

```js
function sendGetRequest(url, callback) {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
callback(JSON.parse(xhr.responseText));
}
else {
console.log('something went wrong');
}
}
}
xhr.open('GET', url);
xhr.send();
}

sendGetRequest('https://chain-chess.glitch.me', console.log);
```