Send a PATCH request and receive the response.
This machine is designed for making basic requests to a modern JSON API. For more flexibility, including more encoding options and the ability to attach custom request headers, use the lower-level machine: `sendHttpRequest()`.
var HTTP = require('machinepack-http');
// Send a PATCH request and receive the response.
HTTP.patch({
url: '/7/friends/search',
data: {},
headers: {},
baseUrl: 'api.example.com/pets',
}).exec({
// An unexpected error occurred.
error: function (err) {
},
// A non-2xx status code was returned from the server.
non200Response: function (result) {
},
// Unexpected connection error: could not send or receive HTTP request.
requestFailed: function () {
},
// OK.
success: function (result) {
},
});
The URL where the request should be sent.
'/7/friends/search'
Optional data to send with this request.
{}
Custom headers to include in the request (e.g. {"X-Auth": "k3yboardc4t"}).
{}
An optional base URL to resolve the main `url` against.
'api.example.com/pets'
An unexpected error occurred.
A non-2xx status code was returned from the server.
{
statusCode: 404,
headers: {},
body: '...[{"maybe some JSON": "like this"}] (but could be any string)'
}
Unexpected connection error: could not send or receive HTTP request.
OK.
'*'