The DayPilot.Http.patch() method makes an HTTP request to the specified URL using the PATCH method.
The syntax and behavior is inspired by axios.
DayPilot.Http.patch(url[, data[, options]]);
data
- the HTTP request body; if this is an object, it will be converted to JSON using JSON.stringify()
; a string is passed as is
options.contentType
- request body content type (string
). Default value is "application/json"
(if data
is an object) or "text/plain"
for other types.
options.headers
- an object with header values
The DayPilot.Http.patch()
method returns a promise. If the HTTP response status code is 200, 201, 204 or 304 the promise is resolved, otherwise it is rejected.
The success handler receives an args
object as an argument:
args.request
- XMLHttpRequest object used for making the request
args.data
- event data received from the server, converted from JSON to object using JSON.parse()
The error handler receives an args
object as an argument:
args.request
- XMLHttpRequest object used for making the request
const data = {
name: "John"
};
const id = 1;
const {data: result} = await DayPilot.Http.patch(`/user/${id}`, data);
console.log("result", result);