'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-b8c5f2d4.js');

const RestController = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
  }
  /**
   * Makes a request to a features REST API. It resolves to the server
   * response object.
   * @param feature GeoJSON feature to be sent to the API.
   * @param options Options object.
   */
  async create(feature, options) {
    let headers = {};
    headers["Content-Type"] = "application/json";
    if (options.token != undefined)
      headers["Authorization"] = "Bearer " + options.token;
    return await fetch(options.url, {
      body: options.method === "GET" ? undefined : JSON.stringify(feature),
      headers: headers,
      method: options.method || "POST",
      mode: options.mode || "cors",
    });
  }
};

exports.gl_rest_controller = RestController;

//# sourceMappingURL=gl-rest-controller.cjs.entry.js.map