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

Glenna ·
更新时间:2024-11-15
· 597 次阅读

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:


作者:@Within



BY DEFAULT user superagent header

需要 登录 后方可回复, 如果你还没有账号请 注册新账号