Axios는 클라이언트 사이드와 서버 사이드의 통신을 위한 HTTP 비동기 통신 라이브러리이다.
npm i axios
를 통해 설치할 수 있으며
import axios from 'axios';
import 문을 통해 세팅할 수 있다.
주로 사용하는 Method
1. GET
- 입력한 url이 존재하는 자원에 요청을 보낸다.
axios.get(url,[,config])
예시)
axios.get('http://localhost:8000/user/userinfo').then((response)=>{
let info = response.data;
console.log(info);
})
2. POST
- 새로운 리소스를 생성할 때 사용한다.
axios.post("url",{
data객체
},[,config])
3. DELETE
- REST 기반 API 프로그램에서 데이터베이스에 저장되어 있는 내용을 삭제하는 목적으로 사용한다.
axios.delete(URL,[,config]);
4. PUT
- REST 기반 API 프로그램에서 데이터베이스에 저장되어 있는 내용을 갱신하는 목적으로 사용된다.
axios.put(url[, data[, config]])'Node.js' 카테고리의 다른 글
| [Node.js] Google Vision Api OCR / 텍스트 추출하기 / Tesseract? (0) | 2024.12.11 |
|---|---|
| [Node.js] Multer (0) | 2024.11.20 |
| [Node] passport (0) | 2024.11.08 |
| [express] Session (0) | 2024.06.04 |
| [Node] Body-Parser (1) | 2024.02.27 |