davRequest
davRequest
core request function of the library,
based on cross-fetch, so the api should work across browser and Node.js
using xml-js so that js objects can be passed as request.
const [result] = await davRequest({
url: 'https://caldav.icloud.com/',
init: {
method: 'PROPFIND',
namespace: 'd',
body: {
propfind: {
_attributes: {
'xmlns:d': 'DAV:',
},
prop: { 'd:current-user-principal': {} },
},
},
headers: {
authorization: 'Basic x0C9uFWd9Vz8OwS0DEAtkAlj',
},
},
});
Arguments
urlrequired, request urlinitrequired, DAVRequest ObjectconvertIncomingdefaults totrue, whether to convert the passed in init object request body, iffalse, davRequest would expectinit->bodyisxmlstring, and would send it directly to targeturlwithout processing.parseOutgoingdefaults totrue, whether to parse the return value in response body, iffalse, the responserawwould be rawxmlstring returned from server.
Return Value
array of DAVResponse
- response-> raw will be
stringifparseOutgoingisfalseor request failed.
Behavior
depend on options, use xml-js to convert passed in json object into valid xml request,
also use xml-js to convert received xml response into json object.
if request failed, response-> raw will be raw response text returned from server.