JavaScript - 'fetch'와 'async/await'로 깔끔하게 API 통신하기
2025. 10. 22. 15:01
JavaScript
분석할 예제 코드 (GET)async function testFatch() { try { // 1. fetch로 서버에 요청 const response = await fetch(g_context + '/test/Info.do', { method: 'GET', headers: { 'Accept': 'application/json;' }, cache: 'no-store' // 캐시 사용 안 함 }); // 2. HTTP 응답 상태 체크 if (!response.ok) { let errorMsg = '정보 조회 중 오류..