{"name":"browser-request","version":"0.1.0-beta2","author":{"name":"Jason Smith","email":"jhs@iriscouch.com"},"description":"Browser port of the Node.js 'request' package","keywords":["request","http","browser","ender"],"homepage":"http://github.com/iriscouch/browser-request","repository":{"type":"git","url":"git://github.com/iriscouch/browser-request.git"},"dependencies":{},"devDependencies":{"tap":"0.1.3"},"engines":["node"],"ender":"./release/ender/ender.js","_npmUser":{"name":"jhs","email":"jhs@iriscouch.com"},"_id":"browser-request@0.1.0-beta2","_engineSupported":true,"_npmVersion":"1.1.0-beta-4","_nodeVersion":"v0.6.6","_defaultsLoaded":true,"dist":{"shasum":"48e942ec27b23e4149515d9aac3b44525e560e34","tarball":"http://registry-npm.ywwl.com/browser-request/download/browser-request-0.1.0-beta2.tgz","integrity":"sha512-Tz+IIY8wiKUGPpU75/lUZpfsxZJX+5PB7ZGwQJZ1rKRh2iP2EZP/nMgm3nbVaUfIrCPdqWE+Dh4VjViEV5aG/g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbhY7tSrdSu1THqzAjkCdQHKjBhHxvjvhTDPw9WEH2RQIhAKFBHf07XiKgivgaJ2F9kknMsSC28A/WjM63aGkk+sm7"}],"size":63594,"noattachment":false,"key":"/browser-request/-/browser-request-0.1.0-beta2.tgz"},"maintainers":[{"name":"jhs","email":"jhs@iriscouch.com"}],"directories":{},"readme":"# Browser Request: The easiest HTTP library you'll ever see\n\nBrowser Request is a port of Mikeal Rogers's ubiquitous and excellent [request][req] package to the browser.\n\nJealous of Node.js? Pining for clever callbacks? Request is for you.\n\nDon't care about Node.js? Looking for less tedium and a no-nonsense API? Request is for you too.\n\n[![browser support](https://ci.testling.com/iriscouch/browser-request.png)](https://ci.testling.com/maxogden/browser-request)\n\n# Examples\n\nFetch a resource:\n\n```javascript\nrequest('/some/resource.txt', function(er, response, body) {\n  if(er)\n    throw er;\n  console.log(\"I got: \" + body);\n})\n```\n\nSend a resource:\n\n```javascript\nrequest.put({uri:'/some/resource.xml', body:'<foo><bar/></foo>'}, function(er, response) {\n  if(er)\n    throw new Error(\"XML PUT failed (\" + er + \"): HTTP status was \" + response.status);\n  console.log(\"Stored the XML\");\n})\n```\n\nTo work with JSON, set `options.json` to `true`. Request will set the `Content-Type` and `Accept` headers, and handle parsing and serialization.\n\n```javascript\nrequest({method:'POST', url:'/db', body:'{\"relaxed\":true}', json:true}, on_response)\n\nfunction on_response(er, response, body) {\n  if(er)\n    throw er\n  if(result.ok)\n    console.log('Server ok, id = ' + result.id)\n}\n```\n\nOr, use this shorthand version (pass data into the `json` option directly):\n\n```javascript\nrequest({method:'POST', url:'/db', json:{relaxed:true}}, on_response)\n```\n\n## Convenient CouchDB\n\nBrowser Request provides a CouchDB wrapper. It is the same as the JSON wrapper, however it will indicate an error if the HTTP query was fine, but there was a problem at the database level. The most common example is `409 Conflict`.\n\n```javascript\nrequest.couch({method:'PUT', url:'/db/existing_doc', body:{\"will_conflict\":\"you bet!\"}}, function(er, resp, result) {\n  if(er.error === 'conflict')\n    return console.error(\"Couch said no: \" + er.reason); // Output: Couch said no: Document update conflict.\n\n  if(er)\n    throw er;\n\n  console.log(\"Existing doc stored. This must have been the first run.\");\n})\n```\n\nSee the [Node.js Request README][req] for several more examples. Request intends to maintain feature parity with Node request (except what the browser disallows). If you find a discrepancy, please submit a bug report. Thanks!\n\n# Usage\n\n## Browserify\n\nBrowser Request is a [browserify][browserify]-enabled package.\n\nFirst, add `browser-request` to your Node project\n\n    $ npm install browser-request\n\nNext, make a module that uses the package.\n\n```javascript\n// example.js - Example front-end (client-side) code using browser-request via browserify\n//\nvar request = require('browser-request')\nrequest('/', function(er, res) {\n  if(!er)\n    return console.log('browser-request got your root path:\\n' + res.body)\n\n  console.log('There was an error, but at least browser-request loaded and ran!')\n  throw er\n})\n```\n\nTo build this for the browser, run it through browserify.\n\n    $ browserify --entry example.js --outfile example-built.js\n\nDeploy `example-built.js` to your web site and use it from your page.\n\n```html\n  <script src=\"example-built.js\"></script> <!-- Runs the request, outputs the result to the console -->\n```\n\n## UMD\n\n`browser-request` is [UMD](https://github.com/umdjs/umd) wrapped, allowing you to serve it directly to the browser from wherever you store the module.\n\n```html\n  <script src=\"/node_modules/browser-request/index.js\"></script> <!-- Assigns the module to window.request -->\n```\n\nYou may also use an [AMD loader](http://requirejs.org/docs/whyamd.html) by referencing the same file in your loader [config](http://requirejs.org/docs/api.html#config).\n    \n## License\n\nBrowser Request is licensed under the Apache 2.0 license.\n\n","publish_time":1324484789624,"_cnpm_publish_time":1324484789624,"dist-tags":{"latest":"0.3.3"}}