Ajac in React, Fetch, promise 본문
Ajax(Asynchronous JavaScript and XML)
비동기 데이터 교환
fetch( 'https://mywebsite.com/mydata.json' );
임의의 URL에서 콘텐츠를 가져오려면 URL fetch에 전달
fetch('https://mywebsite.com/endpoint/', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
firstParam: 'yourValue',
secondParam: 'yourOtherValue',
}),
});
HTTP 요청을 사용자 정의 . 추가 헤더를 지정하거나 POST 요청을 할 수 있음.
'ReactJS' 카테고리의 다른 글
Component State (0) | 2018.10.30 |
---|---|
Component Life Cycle (0) | 2018.10.30 |
컴포넌트 , Props (0) | 2018.10.30 |
ReactJS 설치 (0) | 2018.10.29 |
Comments