File: src/lib/HTTP.js

Recommend this page to a friend!
  Classes of Dom Hastings  >  JS Webdav Client  >  src/lib/HTTP.js  >  Download  
File: src/lib/HTTP.js
Role: Class source
Content type: text/plain
Description: Class source
Class: JS Webdav Client
Access files of a Webdav server
Author: By
Last change:
Date: 1 year ago
Size: 756 bytes
 

Contents

Class file image Download
import EventObject from './EventObject'; const defaultParams = { PROPFIND: { headers: { Depth: 1 } } }; export default class HTTP extends EventObject {} // map convenience methods: HTTP.GET(url, props) ['GET', 'HEAD', 'PUT', 'PROPFIND', 'DELETE', 'MKCOL', 'COPY', 'MOVE'].forEach( (method) => { HTTP.prototype[method] = function(url, parameters) { return fetch(url, { ...(defaultParams[method] || null), ...parameters, method }) .then((response) => { if (! response.ok) { this.trigger('error', { method, url, response }); return; } return response; }); }; } );