Skip to content

Instantly share code, notes, and snippets.

@antondevv
Created February 12, 2022 17:03
Show Gist options
  • Save antondevv/298bd8667da3220d2203fea2ba481307 to your computer and use it in GitHub Desktop.
Save antondevv/298bd8667da3220d2203fea2ba481307 to your computer and use it in GitHub Desktop.
callback hell
const user = new XMLHttpRequest();
user.open("GET", "/user");
user.send();
user.onload = () => {
const getPosts = new XMLHttpRequest();
getPosts.open("GET", `/posts${user.response.id}`);
getPosts.send();
getPosts.onload = () => {
const getMessages = new XMLHttpRequest();
getMessages.open("GET", `/messages${user.response.id}`);
getMessages.send();
getMessages.onload = () => {
// Stop loading and show the useer data on the screen
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment