@colearn/microservices-kit
Advanced tools
Comparing version 0.0.49 to 0.0.50
@@ -10,2 +10,7 @@ /// <reference types="node" /> | ||
}, token?: string): Promise<Response>; | ||
fetchData<T extends { | ||
error: any; | ||
}>(url: string, init?: RequestInit & { | ||
params?: URLSearchParams | string; | ||
}, token?: string): Promise<T>; | ||
} | ||
@@ -12,0 +17,0 @@ export declare class ClientFactory<T> { |
@@ -8,2 +8,3 @@ "use strict"; | ||
const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch")); | ||
const errors_1 = require("./errors"); | ||
class MicroserviceHttpClient { | ||
@@ -31,2 +32,11 @@ constructor(baseURL, token) { | ||
} | ||
async fetchData(url, init = {}, token) { | ||
var _a; | ||
const resp = await this.fetch(url, init, token); | ||
const data = (await resp.json()); | ||
if (!resp.ok || data.error) { | ||
throw new errors_1.InternalServerError((_a = data.error) === null || _a === void 0 ? void 0 : _a.message); | ||
} | ||
return data; | ||
} | ||
} | ||
@@ -33,0 +43,0 @@ exports.MicroserviceHttpClient = MicroserviceHttpClient; |
{ | ||
"name": "@colearn/microservices-kit", | ||
"version": "0.0.49", | ||
"version": "0.0.50", | ||
"description": "colearn microservice kit", | ||
@@ -5,0 +5,0 @@ "author": "Colearn", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71832
1144