728x90
axios는 node js와 클라이언트(크롬, 익스플로어 모두 지원)를 위한 http 통신 라이브러리입니다.
패키지 다운로드 방법은
npm install axios를 사용하면 할 수 있습니다.
get과 post방식이 있습니다.
1.get방식
const axios = require('axios')
axios({
method : 'get',
url : 'https://www.naver.com/'
}).then((res)=>{
console.log(res)
})
2.post방식
const axios = require('axios')
axios.post('http://localhost:3000/axios',{
name : 'balmostory'
}).then((res)=>{
console.log(res)
})
post방식은 url을 쓰고 보낼 데이터를 {}안에 json형식으로 넣어주시면 됩니다.
728x90
'기타 > node js' 카테고리의 다른 글
node js ajax post 예제 (0) | 2021.01.18 |
---|---|
[ Node js] nest js란? (0) | 2020.12.30 |
[Node js] express 서버 예제 (0) | 2020.12.28 |
[Node js] request 모듈 사용법 (0) | 2020.12.25 |
[Node js] chalk로 log colors 지정하기. (0) | 2020.12.23 |