Skip to content

Instantly share code, notes, and snippets.

@ohoroyoi
Created July 13, 2019 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohoroyoi/24b2fbd15a7394325d7d0e83b3766960 to your computer and use it in GitHub Desktop.
Save ohoroyoi/24b2fbd15a7394325d7d0e83b3766960 to your computer and use it in GitHub Desktop.
async await 정말 편하조
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