axios๋?
๋ธ๋ผ์ฐ์ ์ node.js์์ ์ฌ์ฉํ ์ ์๋ Promise ๊ธฐ๋ฐ HTTP ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
ํน์ง
- ๋ธ๋ผ์ฐ์ ๋ฅผ ์ํด XMLHttpRequests ์์ฑ
- node.js๋ฅผ ์ํด http ์์ฒญ ์์ฑ
- Promise API๋ฅผ ์ง์
- ์์ฒญ ๋ฐ ์๋ต ์ธํฐ์ ํธ
- ์์ฒญ ๋ฐ ์๋ต ๋ฐ์ดํฐ ๋ณํ
- ์์ฒญ ์ทจ์
- JSON ๋ฐ์ดํฐ ์๋ ๋ณํ
- XSRF๋ฅผ ๋ง๊ธฐ์ํ ํด๋ผ์ด์ธํธ ์ฌ์ด๋ ์ง์
์ค์น
npm install axios
์ฌ์ฉ ์์
// POST ์์ฒญ ์ ์ก
axios({
method: 'post',
url: '/user/12345',
data: {
firstName: 'Fred',
lastName: 'Flintstone'
}
});
// node.js์์ GET ์์ฒญ์ผ๋ก ์๊ฒฉ ์ด๋ฏธ์ง ๊ฐ์ ธ์ค๊ธฐ
axios({
method: 'get',
url: '<http://bit.ly/2mTM3nY>',
responseType: 'stream'
})
.then(function (response) {
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
});
Reference
์์ํ๊ธฐ | Axios Docs
์์ํ๊ธฐ ๋ธ๋ผ์ฐ์ ์ node.js์์ ์ฌ์ฉํ ์ ์๋ Promise ๊ธฐ๋ฐ HTTP ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ Axios๋? Axios๋ node.js์ ๋ธ๋ผ์ฐ์ ๋ฅผ ์ํ Promise ๊ธฐ๋ฐ HTTP ํด๋ผ์ด์ธํธ ์ ๋๋ค. ๊ทธ๊ฒ์ ๋ํ ์ ๋๋ค(๋์ผํ ์ฝ
axios-http.com
'Development' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ฐ๋ฒจ(Babel) (0) | 2023.06.15 |
---|---|
์นํฉ(Webpack) (0) | 2023.06.15 |
[axios] axios 2 (0) | 2023.01.27 |
[npm].npmrc (0) | 2023.01.19 |
๋๊ธ