sync async

김듑듑·2022년 7월 20일

언제까지 async await, promise then으로 고통받을까

https://anywaydevlog.tistory.com/30


상황1.

axios 요청을 1, 2, 3 순서대로 날려야함
그래서 일케함 근데 요상하게 동작함 그럴만두

1
.then(
	2
    .then(3)
)

그래서 이렇게 코드 바꿈

async function hey(){
  await 1
  await 2
  await 3
}

상황2.

axios get 하면 return 값이 promise라네

https://blckchainetc.tistory.com/entry/JavaScript-Promise-%EA%B0%92-%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0-async-await-%EC%82%AC%EC%9A%A9

근데 .then을 쓰면 then 안에서만 써야함
그럼 await로 값을 가져와야함


'await'는 이 식의 형식에 영향을 주지 않습니다.

https://stackoverflow.com/questions/60368017/await-has-no-effect-on-the-type-of-this-expression

0개의 댓글