web/javascript

fetch - 옵션

내가 만드는게 길이 된다 2026. 1. 14. 22:23

fetch('http://localhost:8080/?apiKey=123&parm=abc', {
  method : 'GET',
  headers : {
    'Content-Type' : 'application/json'
  },
  body : JSON.stringify({
    name : 'aaa',
    age : 33,
    email : 'test@test.com'
  })
})
.then(res => res.json)
.then.(json => console.log(json)
;
//method 는 GET,POST,PUT,DELETE
//body 부분은 문자화

const proc  = async () => {
let res = await fetch('http://localhost:8080/?apiKey=123&parm=abc');
let json = await res.json();
console.log(json);
}

proc();

'web > javascript' 카테고리의 다른 글

fetch  (0) 2026.01.14
callBack - for  (0) 2026.01.14
callBack - for  (0) 2026.01.14
callBack - fetch  (0) 2026.01.14
callBack - Reject  (0) 2026.01.13