Created
February 12, 2022 17:03
-
-
Save antondevv/298bd8667da3220d2203fea2ba481307 to your computer and use it in GitHub Desktop.
callback hell
This file contains 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 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