본문 바로가기

카테고리 없음

23.10.27 보충반 특강 정리

728x90
반응형

1, await = a+wait  

해당 결과값이 나올때까지 기다리게 하는 명령어 (얼마나 오래걸리든)

ex   const result1 = await fetch(`dfdfsfsdfsdfsdsfdfsdf`)

       const result2 = await fetch(`dfdfsfsdfsdfsdsfdfsdf`)

await 을 사용하면 해당 작업이 끝날때까지 기다림 근데 만약 마지막 result2가 오래걸리는 작업이라면 (20초씩)

빼도 무관함 아니면 밑에 코드가 작동안함 

await 가있는 블록은 async블록 

const func01 = async function () { 

 const result1 = await fetch(`dfdfsfsdfsdfsdsfdfsdf`)

 const result2 = await fetch(`dfdfsfsdfsdfsdsfdfsdf`,resulit1)

}

 2, try ~catch

 뭔가를 시도해서 잡는다 

오류잡기용 

try {
const func01 = async function () { 

 const result1 = await fetch(`dfdfsfsdfsdfsdsfdfsdf`)

 const result2 = await fetch(`dfdfsfsdfsdfsdsfdfsdf`,resulit1)

} catch {
}

실사용 예시 

const func01 + async function () {
try { 
const result01 = await fetch( `https 주소`);
const result01 = await fetch( `https 주소`);
} catch (error) {
consoel.log(`알수없는 오류 발생했습니다`);
	}
}

 

사실 제일중요한 내용은 남들이랑 비교하지말기 

 

하루 일주일 한달 구체적인 계획세워서 실행하기

열심히 해보자...

728x90
반응형