우연히 쓸 일이 생겨서, HTTP Request 라이브러리들을 정리해보았다.
개인적으로는 가벼움 때문에 superagent를 사용하였으며,
사실상 request와 거의 똑같이 쓸 수 있는 구조로 되어 있어 편리하게 사용하였다.
공식 문서 : https://github.com/request/request
request/request
🏊🏾 Simplified HTTP request client. Contribute to request/request development by creating an account on GitHub.
github.com
상당히 다양한 HTTP request 형식을 지원하고 있고, npm 초창기부터 있던 모듈이다.
2020년 2월 11일 이후로 deprecated 되었다고 한다!
request
  .get('http://google.com/img.png')
  .on('response', function(response) {
    console.log(response.statusCode) // 200
    console.log(response.headers['content-type']) // 'image/png'
  })
  .pipe(request.put('http://mysite.com/img.png'))
공식 문서 : https://github.com/axios/axios
axios/axios
Promise based HTTP client for the browser and node.js - axios/axios
github.com
const axios = require('axios');
// Make a request for a user with a given ID
axios.get('/user?ID=12345')
  .then(function (response) {
    // handle success
    console.log(response);
  })
  .catch(function (error) {
    // handle error
    console.log(error);
  })
  .then(function () {
    // always executed
  });
공식 문서 : https://visionmedia.github.io/superagent/
SuperAgent — elegant API for AJAX in Node and browsers
SuperAgent SuperAgent is light-weight progressive ajax API crafted for flexibility, readability, and a low learning curve after being frustrated with many of the existing request APIs. It also works with Node.js! request .post('/api/pet') .send({ name: 'Ma
visionmedia.github.io
아직 많은 유저들이 쓰고 있는 거 같지는 않다.
 request
   .post('/api/pet')
   .send({ name: 'Manny', species: 'cat' })
   .set('X-API-Key', 'foobar')
   .set('Accept', 'application/json')
   .then(res => {
      alert('yay got ' + JSON.stringify(res.body));
   });
| Express.js를 처음 접할 때, 알면 좋을 개념 3가지 (2) | 2018.07.25 | 
|---|
댓글 영역