Please note that v5.0.1+ of superagent removes User-Agent header by default,

SuperAgent is a small progressive client-side HTTP request library, and Node.js module with the same API, sporting many high-level HTTP client features. View the docs.

Installation

node:

$ npm install superagent

Works with browserify and webpack.


 

request

  .post('/api/pet')

  .send({ name: 'Manny', species: 'cat' }) // sends a JSON post body

  .set('X-API-Key', 'foobar')

  .set('accept', 'json')

  .end((err, res) => {

    // Calling the end function will send the request

  });

Supported browsers and Node versions

Tested browsers:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章