@colearn/microservices-kit
Advanced tools
Comparing version 0.0.46 to 0.0.47
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { RequestInit, Response } from 'node-fetch'; | ||
@@ -6,3 +7,5 @@ export declare class MicroserviceHttpClient { | ||
constructor(baseURL: string, token?: string | undefined); | ||
protected fetch(url: string, init?: RequestInit, token?: any): Promise<Response>; | ||
protected fetch(url: string, init?: RequestInit & { | ||
params?: URLSearchParams | string; | ||
}, token?: string): Promise<Response>; | ||
} |
@@ -13,12 +13,14 @@ "use strict"; | ||
} | ||
async fetch(url, init, token) { | ||
async fetch(url, init = {}, token) { | ||
var _a; | ||
const { params, ...rest } = init || {}; | ||
const headers = { | ||
'Content-Type': 'application/json', | ||
}; | ||
if (token) { | ||
headers['Authorization'] = `Bearer ${token}`; | ||
const t = token || this.token; | ||
if (t) { | ||
headers['Authorization'] = `Bearer ${t}`; | ||
} | ||
const response = await (0, isomorphic_fetch_1.default)(`${this.baseURL}/${url}`, { | ||
...(init !== null && init !== void 0 ? init : {}), | ||
const response = await (0, isomorphic_fetch_1.default)(`${this.baseURL}/${url}${params ? `?${params.toString()}` : ''}`, { | ||
...(rest !== null && rest !== void 0 ? rest : {}), | ||
method: (_a = init === null || init === void 0 ? void 0 : init.method) !== null && _a !== void 0 ? _a : 'GET', | ||
@@ -25,0 +27,0 @@ headers, |
{ | ||
"name": "@colearn/microservices-kit", | ||
"version": "0.0.46", | ||
"version": "0.0.47", | ||
"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
70163
1113