-
[React] Axios - [GET, POST,PUT,DELETE] 기본 사용법Front End/React 2021. 11. 30. 21:02
# Axios
- CSRF 보호기능 내장
- JSON 데이터 자동변환
- 응답시간 초과 커스터마이징 가능
- 요청 중단 가능
- Promise 기반 async/await 문법 가능
import axios from 'axios' // GET : Fetch a list of data axios.get(`url`) .then(function1) .catch(ErrorHandlingFunction) .finally(function2); // POST : Create new data axios.post(`url`, {json}) .then(function1) .catch(ErrorHandlingFunction) .finally(function2); // PUT : Update data axios.put(`url`, {json}) .then(function1) .catch(ErrorHandlingFunction) .finally(function2); // DELETE : Delete data axios.put(`url`) .then(function1) .catch(ErrorHandlingFunction) .finally(function2); /* URL 구성방식 /users [GET] # Fetch a list of users /users [POST] # Create new user /users/123 [PUT] # Update user /users/123 [DELETE] # remove user */
# Reference
Axios를 사용하여 HTTP요청하기
Axios소개Axios는 HTTP통신을 하는데 매우 인기있는 Javascript라이브러리입니다. Axios는 브라우저와 Node.js 플랫폼에서 모두 사용할 수 있습니다. 또한 IE8이상을 포함한 모든 최신 브라우저를 지원합니
tuhbm.github.io
728x90'Front End > React' 카테고리의 다른 글