base.js 990 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. export class BaseResponse {
  2. /**
  3. * Returns whether the response has an ok'ish status code
  4. */
  5. get ok() {
  6. return this.status >= 200 && this.status <= 299;
  7. }
  8. /**
  9. * Returns the status code of the response
  10. */
  11. get status() {
  12. throw new Error('not implemented');
  13. }
  14. /**
  15. * Returns the value of the specified header
  16. * @param {string} headerName the header name
  17. * @returns {string} the header value
  18. */
  19. getHeader(headerName) { // eslint-disable-line no-unused-vars
  20. throw new Error('not implemented');
  21. }
  22. /**
  23. * @returns {ArrayBuffer} the response data of the request
  24. */
  25. async getData() {
  26. throw new Error('not implemented');
  27. }
  28. }
  29. export class BaseClient {
  30. constructor(url) {
  31. this.url = url;
  32. }
  33. /**
  34. * Send a request with the options
  35. * @param {object} [options]
  36. */
  37. async request({ headers, credentials, signal } = {}) { // eslint-disable-line no-unused-vars
  38. throw new Error('request is not implemented');
  39. }
  40. }