docs/reference/websockets/sails.io.js/socket.put.md
io.socket.put()Send a socket request (virtual PUT) to a Sails server using Socket.IO.
io.socket.put(url, data, function (resData, jwres){
// ...
});
| Argument | Type | Details | |
|---|---|---|---|
| 1 | url | ((string)) | The destination URL path, e.g. "/checkout". |
| 2 | data | ((json?)) | Optional request data. If provided, it will be JSON-encoded and included as the virtual HTTP body. |
| 3 | callback | ((function?)) | Optional callback. If provided, it will be called when the server responds. |
| Argument | Type | Details | |
|---|---|---|---|
| 1 | resData | ((json)) | Data received in the response from the Sails server (=== jwres.body, equivalent to the HTTP response body). |
| 2 | jwres | ((dictionary)) | A JSON WebSocket Response object. Has headers, a body, and a statusCode. |
<script>
io.socket.put('/users/9', { occupation: 'psychic' }, function (resData, jwr) {
resData.statusCode; // => 200
});
</script>
<docmeta name="displayName" value="io.socket.put()"> <docmeta name="pageType" value="method">
- Remember that you can communicate with any of your routes using socket requests.
- Need to customize request headers? Check out the slightly lower-level
io.socket.request()method. To set custom headers for all outgoing requests, check outio.sails.headers.