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
url
required, request urlinit
required, DAVRequest ObjectconvertIncoming
defaults totrue
, whether to convert the passed in init object request body, iffalse
, davRequest would expectinit->body
isxml
string, and would send it directly to targeturl
without processing.parseOutgoing
defaults totrue
, whether to parse the return value in response body, iffalse
, the responseraw
would be rawxml
string returned from server.fetchOptions
options to pass to underlying fetch function
Return Value
array of DAVResponse
- response-> raw will be
string
ifparseOutgoing
isfalse
or 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.