socket.get()

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

Usage

  1. io.socket.get(url, data, function (data, jwres){
  2. // ...
  3. });
Argument Type Details
1 url ((string)) The destination URL path, e.g. “/checkout”.
2 data ((*)) Optional request data- if provided, will be URL encoded and appended to url (existing query string params in url will be preserved)
3 callback ((function)) Optional callback- if provided, will be called when the server responds.
Callback
Argument Type Details
1 resData ((*)) Data received in the response from the Sails server (=== jwres.body, equivalent to the HTTP response body.)
2 jwres ((JWR)) The JSON WebSocket Response object. Has headers, a body, and a statusCode.

Example

  1. <script>
  2. io.socket.get('/users/9', function (resData) {
  3. resData; // => {id:9, name: 'Timmy Mendez'}
  4. });
  5. </script>