File: server.coffee

Defined in: lib/resin/server

Method Summary

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}")

Parameters:

  • options ( Object ) request options
  • callback ( Function ) callback(error, response, body)
  • onProgress ( Function ) on progress callback(state) (optional)

Options Hash: (options):

  • url ( String ) relative url
  • json ( String ) request body
  • method ( String ) HTTP method
  • headers ( Object ) custom HTTP headers
  • pipe ( Function ) define this function if you want to stream the response

Throws:

  • ( Error ) — Will throw if you don't have internet connection

~ (void) createFacadeFunction(method) Private

TODO: Find a way to document all of the methods directly

Generate shorthand functions for every method

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: