The DayPilot.Http.post() method makes an HTTP request to the specified URL using the POST method.
The syntax and behavior is inspired by axios.
It is a static method.
Declaration
DayPilot.Http.post(url[, data[, options]]);Parameters
url(string) - URL of the HTTP requestdata- the POST body. If this is an object, it will be converted to JSON usingJSON.stringify(); a string is passed as is.options.contentType(string, optional) - request body content type. The default value is"application/json"ifdatais an object, or"text/plain"for other types.options.headers(object, optional) - an object with header values
Return Value
The DayPilot.Http.post() method returns a promise. If the HTTP response status code is 200, 201, 204, or 304, the promise is resolved; otherwise it is rejected.
Resolved promise handlers receive an args object with the following properties:
args.request-XMLHttpRequestobject used for making the requestargs.data- event data received from the server, converted from JSON to object usingJSON.parse()
Rejected promise handlers receive an args object with the following property:
args.request-XMLHttpRequestobject used for making the request
Example
const data = {
name: "John"
};
const {data: result} = await DayPilot.Http.post("/createUser", data);
console.log("result", result);See Also
Event Moving Validation [doc.daypilot.org]
Event Resizing Validation [doc.daypilot.org]
Row Editing [doc.daypilot.org]
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
DayPilot