1. async await promise 의 정의와 쓰는 방법을 대강 알기 때문에 제대로 해보자!

기억나는대로 async와 await가 짝꿍이므로 async 와 await를 이용하여 값을 받아왔다.

async function printData() {
    const datas = await getBoardList(null,);
    console.log(datas);
    const data = datas.map(x => x);
    console.log(data);
    return data;
  }

하지만 본인은 하나의 변수를 선언한 다음 data의 받아온 값을 넣고 싶었다. 그래서

const dataResult = printData();
console.log(dataResult);

를 하니 Promise(pending(…)) 이 뜨는걸 확인할 수 있었다. 왜 그럴가?

이걸 알기 위해서는 Async 와 Promise의 관계를 알아야 한다.

Promise에서는 3가지 상태가 존재한다.

즉 Pending이 떳다는 건 아직 비동기 처리가 완료가 되지 않아 발생한 거라고 알 수 있다.

자 그러면 다시 코드로 돌아와서 살펴보자