trooba-xhr-transport
v2.0.2
Published
AJAX/XHR transport for trooba pipeline
Downloads
7
Readme
trooba-xhr-transport
XHR transport for trooba pipeline to make CORS RESTful service calls from the browser.
Get Involved
- Contributing: Pull requests are welcome!
- Read
CONTRIBUTING.md
and check out our bite-sized and help-wanted issues - Submit github issues for any feature enhancements, bugs or documentation problems
- Read
- Support: Join our gitter chat to ask questions to get support from the maintainers and other Trooba developers
- Questions/comments can also be posted as github issues
Install
npm install trooba-xhr-transport --save
Usage
var xhrTransport = require('trooba-xhr-transport');
require('trooba')
.use(xhrTransport, {
protocol: 'http:',
hostname: 'www.google.com'
socketTimeout: 1000
})
.build()
.create('client:default')
.get({
q: 'nike'
})
.set('some', 'header')
.end(function (err, response) {
console.log(err, response && response.body)
});
For a real browser example, take a look at unit test. It uses lasso-js and marko-js to bundle resources into browser page including trooba xhr implementation.