Created
July 13, 2019 15:57
-
-
Save ohoroyoi/24b2fbd15a7394325d7d0e83b3766960 to your computer and use it in GitHub Desktop.
async await 정말 편하조
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 getTodos = (id) => { | |
return new Promise((resolve, reject) => { | |
$.getJSON(`https://jsonplaceholder.typicode.com/todos/${id}`, (data) => { | |
resolve(data); | |
}); | |
}); | |
} | |
const execute = async () => { | |
console.log('하나'); | |
const dataOne = await getTodos('1'); | |
console.log(dataOne) | |
console.log('둘'); | |
const dataTwo = await getTodos('2'); | |
console.log(dataTwo) | |
} // 비동기 이지만 순차적으로 | |
execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment