Comparing version 10.0.0-beta.19 to 10.0.0-beta.20
@@ -15,3 +15,3 @@ import { CategoryCode, EndpointDescription, HistoricalFilter, News, RestResponse, RestResponseError, RestResponseSuccess, SourceDetails } from "./types"; | ||
put<T, Z>(path: string, body: T, errorHandler?: (apiResponse: RestResponseError<Z>) => void): Promise<RestResponseSuccess<Z>>; | ||
request<T>(method: string, path: string, params?: any, errorHandler?: (apiResponse: RestResponseError<T>) => void): Promise<RestResponse<T>>; | ||
request<T>(method: string, path: string, params?: object, errorHandler?: (apiResponse: RestResponseError<T>) => void): Promise<RestResponse<T>>; | ||
private requestWithBody; | ||
@@ -18,0 +18,0 @@ handle<T>(res: Response, handleError: (apiResponse: RestResponseError<T>) => void): Promise<RestResponse<T>>; |
@@ -72,3 +72,11 @@ "use strict"; | ||
try { | ||
const endpoint = this.restEndpoint + path + (params ? "?" + new URLSearchParams(params) : ''); | ||
var paramsString = {}; | ||
if (params) { | ||
Object.keys(params).forEach(key => { | ||
paramsString[key] = typeof params[key] === "object" | ||
? JSON.stringify(params[key]) | ||
: params[key]; | ||
}); | ||
} | ||
const endpoint = this.restEndpoint + path + (paramsString ? "?" + new URLSearchParams(paramsString) : ''); | ||
const res = yield (0, isomorphic_fetch_1.default)(endpoint, { | ||
@@ -75,0 +83,0 @@ method: method, |
{ | ||
"name": "newsware", | ||
"version": "10.0.0-beta.19", | ||
"version": "10.0.0-beta.20", | ||
"description": "Typescript client for interacting with the Newsware API", | ||
@@ -5,0 +5,0 @@ "main": "lib/src/index.js", |
@@ -81,7 +81,16 @@ import { | ||
path: string, | ||
params?: any, | ||
params?: object, | ||
errorHandler: (apiResponse: RestResponseError<T>) => void = this.handleError | ||
): Promise<RestResponse<T>> { | ||
try { | ||
const endpoint = this.restEndpoint + path + (params ? "?" + new URLSearchParams(params) : '') | ||
var paramsString: Record<string, string> = {} | ||
if (params) { | ||
Object.keys(params).forEach(key => { | ||
paramsString[key] = typeof params[key as keyof object] === "object" | ||
? JSON.stringify(params[key as keyof object]) | ||
: params[key as keyof object] | ||
}) | ||
} | ||
const endpoint = this.restEndpoint + path + (paramsString ? "?" + new URLSearchParams(paramsString) : '') | ||
const res = await fetch(endpoint, { | ||
@@ -88,0 +97,0 @@ method: method, |
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
99675
1974