Socket
Socket
Sign inDemoInstall

@ghii/http-loader

Package Overview
Dependencies
2
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

9

dist/lib/__test__/http-loader.test.js

@@ -28,9 +28,14 @@ "use strict";

}));
it('attempt to make a call that fails silently', () => __awaiter(void 0, void 0, void 0, function* () {
mockedAxios.get.mockRejectedValue({ response: { status: 404 }, message: 'test' });
yield http_loader_1.default('http://localhost:3000/.wellknown')();
}));
it('attempt to make a call that fails', () => __awaiter(void 0, void 0, void 0, function* () {
mockedAxios.get.mockRejectedValue(new Error());
mockedAxios.get.mockRejectedValue({ response: { status: 404 }, message: 'test' });
try {
const test = yield http_loader_1.default('http://localhost:3000/.wellknown')();
yield http_loader_1.default('http://localhost:3000/.wellknown', { throwOnError: true })();
}
catch (err) {
expect(err).toBeDefined();
expect(err.message).toContain('test');
}

@@ -37,0 +42,0 @@ }));

@@ -16,3 +16,3 @@ "use strict";

const axios_1 = __importDefault(require("axios"));
function httpLoader(urlEndpoint, headers) {
function httpLoader(urlEndpoint, { headers, throwOnError = false, logger = (err, message) => console.log(message, err), } = {}) {
return function () {

@@ -25,3 +25,7 @@ return __awaiter(this, void 0, void 0, function* () {

catch (err) {
throw new Error(`Call in error: ${err.message}`);
const msg = `${err.response.status} GET ${urlEndpoint} : ${err.message}`;
logger(err, msg);
if (throwOnError)
throw new Error(msg);
return {};
}

@@ -28,0 +32,0 @@ });

import { Loader } from '@ghii/ghii';
export default function httpLoader(urlEndpoint: string, headers?: any): Loader;
export default function httpLoader(urlEndpoint: string, { headers, throwOnError, logger, }?: {
headers?: any;
throwOnError?: boolean;
logger?: (err: any, message: string) => void;
}): Loader;
//# sourceMappingURL=http-loader.d.ts.map
{
"name": "@ghii/http-loader",
"version": "0.0.2",
"version": "0.0.3",
"description": "A Funny http loader for ghii configuration manager ",

@@ -5,0 +5,0 @@ "maintainers": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc