@haechi-labs/henesis-cli
Version:
🚀 Command Line Interface tool to Utilize henesis
29 lines • 976 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const wretch_1 = tslib_1.__importDefault(require("wretch"));
const defaultErrorCatcher = (error, originalRequest) => {
if (error.json === undefined || error.json.error === undefined) {
throw new Error('invalid response format');
}
throw new Error(error.json.error.message);
};
let wretchInstance = wretch_1.default()
.errorType('json')
.catcher(400, defaultErrorCatcher)
.catcher(401, defaultErrorCatcher)
.catcher(404, defaultErrorCatcher)
.catcher(500, defaultErrorCatcher)
.catcher(503, defaultErrorCatcher)
.polyfills({
fetch: require('node-fetch'),
FormData: require('form-data'),
URLSearchParams: require('url').URLSearchParams,
});
exports.setWretcher = (wretcher) => {
wretchInstance = wretcher;
};
exports.getWretcher = () => {
return wretchInstance;
};
//# sourceMappingURL=wretch.js.map