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 url
- initrequired, DAVRequest Object
- convertIncomingdefaults to- true, whether to convert the passed in init object request body, if- false, davRequest would expect- init->bodyis- xmlstring, and would send it directly to target- urlwithout processing.
- parseOutgoingdefaults to- true, whether to parse the return value in response body, if- false, the response- rawwould be raw- xmlstring 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.