View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

io.socket.request()

Sends a virtual request to a Sails server using Socket.io.

This function is very similar to io.socket.get(), io.socket.post(), etc. except that it provides lower-level access to the request headers, parameters, method, and URL of the request.

This function is provided by the sails.io.js JavaScript client, and is accessible in the browser.

Usage

io.socket.request(options, function (data, jwr)){
  // ...
  // jwr.headers
  // jwr.statusCode
  // jwr.body === data
  // ...
});

Example

io.socket.request({
  method: 'get',
  url: '/user/3/friends',
  params: {},
  headers: {}
})

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book