Skip to content

Instantly share code, notes, and snippets.

@fleepgeek
Created February 6, 2019 11:31
Show Gist options
  • Save fleepgeek/f975db7d3c5d74cb5b156a56ab70e3f0 to your computer and use it in GitHub Desktop.
Save fleepgeek/f975db7d3c5d74cb5b156a56ab70e3f0 to your computer and use it in GitHub Desktop.
document.addEventListener('DOMContentLoaded', () => {
// setTimeout(() => {
// console.log("Hello");
// }, 2000);
// console.log("World");
// setInterval(() => {
// console.log("hi");
// }, 1000)
// console.log("World");
// let req = new XMLHttpRequest();
// req.open("GET", "https://jsonplaceholder.typicode.com/todos/1");
// req.send();
// req.onload = () => {
// if(req.readyState == 4){
// console.log(req.responseText);
// }
// }
// let hasCompletedJob = true;
// let jobStatus = new Promise((resolve, reject) => {
// if(hasCompletedJob) {
// let msg = "I have done the job";
// resolve(msg);
// }else {
// let errorMsg = "I'm Sorry bro. Job Incomplete";
// reject(errorMsg);
// }
// })
// console.log(jobStatus);
// jobStatus
// .then((ok) => console.log(ok))
// .catch((error) => console.log(error))
// let getUsers = () => {
// fetch('https://jsonplaceholder.typicode.com/users')
// .then(function(response) {
// return response.json();
// })
// .then(function(json) {
// // console.log(json);
// })
// }
// getUsers();
// let list = document.querySelector(".list");
// async function asyncGetUsers() {
// let response = await fetch('https://jsonplaceholder.typicode.com/users');
// let jsonData = await response.json();
// return jsonData;
// }
// asyncGetUsers()
// .then(data => {
// data.forEach(element => {
// let item = document.createElement("li");
// item.innerHTML = element.name;
// list.appendChild(item);
// });
// })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment