스프링부트 JS 클라이언트-서버 통신
데이터 전달하기 (js) fetch('/api/give', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(dataToSend) }) .then(response => { if (response.ok) { console.log('데이터를 서버로 전송했습니다.'); } }) .catch(error => { console.error('데이터 전송 중 오류 발생: ' + error); }); 데이터 받기 (js) fetch("/api/hello") .then(response => response.text()) .then(data => { console.log(data); }); 서버 (java) @Res..
카테고리 없음
2023. 10. 25. 13:10