File: server.coffee
Defined in: | lib/resin/server |
Method Summary
-
~
(void)
request(options = {}, outerCallback, onProgress)
Send an HTTP request to resin.io
resin.server.request { method: 'GET' url: '/foobar' }, (error, response, body) -> throw error if error? console.log(body) resin.server.request { method: 'POST' url: '/foobar' json: name: 'My FooBar' }, (error, response, body) -> throw error if error? assert(response.statusCode is 201) resin.server.request { method: 'GET' url: '/download' pipe: fs.createWriteStream('/tmp/download') }, (error) -> throw error if error? , (state) -> console.log("Received: #{state.received}") console.log("Total: #{state.total}") console.log("Is Complete? #{state.complete}")
- ~ (void) createFacadeFunction(method) Private Generate shorthand functions for every method
Method Details
~
(void)
request(options = {}, outerCallback, onProgress)
Note:
If the user is logged in, the token gets automatically added to Authorization header
Note:
If the response is JSON, it will attempt to parse it
Send an HTTP request to resin.io
resin.server.request { method: 'GET' url: '/foobar'
}, (error, response, body) -> throw error if error? console.log(body)
resin.server.request { method: 'POST' url: '/foobar' json:
name: 'My FooBar'
}, (error, response, body) -> throw error if error? assert(response.statusCode is 201)
resin.server.request { method: 'GET' url: '/download' pipe: fs.createWriteStream('/tmp/download')
}, (error) -> throw error if error?
, (state) -> console.log("Received: #{state.received}") console.log("Total: #{state.total}") console.log("Is Complete? #{state.complete}")
~
(void)
createFacadeFunction(method)
Private
TODO:
Find a way to document all of the methods directly
Generate shorthand functions for every method