Edit Page
io.socket.patch()
Send a socket request (virtual PATCH) to a Sails server using Socket.IO.
io.socket.patch(url, data, function (resData, jwres){
});
Usage
#
|
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. |
Callback
#
|
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 . |
Example
#
<script>
io.socket.patch('/users/9', { occupation: 'psychic' }, function (resData, jwr) {
resData.statusCode;
});
</script>
Notes
#
- 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 out io.sails.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 repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.