@magicbell/react-headless
Version:
Hooks to build a notification inbox
27 lines • 812 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const humps_1 = tslib_1.__importDefault(require("humps"));
const ajax_js_1 = require("../../lib/ajax.js");
/**
* Class to interact with the config API endpoint.
*
* @example
* const repo = new ConfigRepository();
* const config = await repo.get();
*/
class ConfigRepository {
remotePathOrUrl;
constructor(remotePathOrUrl = '/config') {
this.remotePathOrUrl = remotePathOrUrl;
}
/**
* Get the configuration from the API server.
*/
async get() {
const json = await (0, ajax_js_1.fetchAPI)(this.remotePathOrUrl);
return humps_1.default.camelizeKeys(json);
}
}
exports.default = ConfigRepository;
//# sourceMappingURL=ConfigRepository.js.map