{"id":7958,"date":"2015-11-12T19:55:55","date_gmt":"2015-11-12T19:55:55","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/12\/visionmedia-superagent\/"},"modified":"2015-11-12T19:55:55","modified_gmt":"2015-11-12T19:55:55","slug":"visionmedia-superagent","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/12\/visionmedia-superagent\/","title":{"rendered":"visionmedia\/superagent"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/saucelabs.com\/browser-matrix\/shtylman-superagent.svg\" \/><\/p>\n<p>SuperAgent is a small progressive <strong>client-side<\/strong> HTTP request library, and <strong>Node.js<\/strong> module with the same API, sporting many high-level HTTP client features. View the docs.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/f.cl.ly\/items\/3d282n3A0h0Z0K2w0q2a\/Screenshot.png\" \/><\/p>\n<h2>Installation<\/h2>\n<p>node:<\/p>\n<pre><code>$ npm install superagent\n<\/code><\/pre>\n<p>component:<\/p>\n<pre><code>$ component install visionmedia\/superagent\n<\/code><\/pre>\n<p>Works with browserify and should work with webpack<\/p>\n<pre><code>request\n  .post('\/api\/pet')\n  .send({ name: 'Manny', species: 'cat' })\n  .set('X-API-Key', 'foobar')\n  .set('Accept', 'application\/json')\n  .end(function(err, res){\n    \/\/ Calling the end function will send the request\n  });\n<\/code><\/pre>\n<h2>Supported browsers<\/h2>\n<p>Tested browsers:<\/p>\n<ul>\n<li>Latest Android<\/li>\n<li>Latest Firefox<\/li>\n<li>Latest Chrome<\/li>\n<li>IE9 through latest<\/li>\n<li>Latest iPhone<\/li>\n<li>Latest Safari<\/li>\n<\/ul>\n<p>Even though IE9 is supported, a polyfill <code>window.btoa<\/code> is needed to use basic auth.<\/p>\n<p>Superagent is easily extended via plugins.<\/p>\n<pre><code>var nocache = require('no-cache');\nvar request = require('superagent');\nvar prefix = require('superagent-prefix')('\/static');\n\nrequest\n.get('\/some-url')\n.use(prefix) \/\/ Prefixes *only* this request\n.use(nocache) \/\/ Prevents caching of *only* this request\n.end(function(err, res){\n    \/\/ Do something\n});\n<\/code><\/pre>\n<p>Existing plugins:<\/p>\n<p>Please prefix your plugin with <code>superagent-*<\/code> so that it can easily be found by others.<\/p>\n<p>For superagent extensions such as couchdb and oauth visit the wiki.<\/p>\n<h2>Running node tests<\/h2>\n<p>Install dependencies:<\/p>\n<pre><code>$ npm install\n<\/code><\/pre>\n<p>Run em!<\/p>\n<pre><code>$ make test\n<\/code><\/pre>\n<h2>Running browser tests<\/h2>\n<p>Install dependencies:<\/p>\n<pre><code>$ npm install\n<\/code><\/pre>\n<p>Start the test runner:<\/p>\n<pre><code>$ make test-browser-local\n<\/code><\/pre>\n<p>Visit <code>http:\/\/localhost:4000\/__zuul<\/code> in your browser.<\/p>\n<p>Edit tests and refresh your browser. You do not have to restart the test runner.<\/p>\n<h2>License<\/h2>\n<p>MIT<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 component: $ component install visionmedia\/superagent Works with browserify and should work with webpack request .post(&#8216;\/api\/pet&#8217;) .send({ name: &#8216;Manny&#8217;, species: &#8216;cat&#8217; }) .set(&#8216;X-API-Key&#8217;, &#8216;foobar&#8217;) .set(&#8216;Accept&#8217;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7958","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7958"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7958\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}