fetch api
async function 함수이름() {
const name = document.getElementById('name').value
fetch(`http://localhost:3000/sound/${name}`)
.then((response) => response.json())
.then((data) => {
console.log(data)
document.getElementById('name').value = data
});
}
// 최신 문법
async function logJSONData() {
const response = await fetch("http://example.com/movies.json");
const jsonData = await response.json();
console.log(jsonData);
}
MDN 사이트에 사용법과 함께 있음.
'FrontEnd > JavaScript' 카테고리의 다른 글
| 개념 정리 (0) | 2025.12.06 |
|---|---|
| JavaScript 기본 개념 (0) | 2025.11.27 |
| 특정 요소 숨기는 기능 classList.toggle() 사용. (0) | 2025.09.10 |