@frui.ts/apiclient
Advanced tools
Comparing version 0.16.0-beta.4 to 0.16.0-beta.5
import { IApiConnector } from "./types"; | ||
import { StringifyOptions } from "query-string"; | ||
export declare function appendAcceptJsonHeader(params?: RequestInit): RequestInit; | ||
export declare const ContentTypes: { | ||
json: string; | ||
}; | ||
export declare function appendAcceptHeader(params: RequestInit | undefined, acceptContentType: string): RequestInit; | ||
export declare function appendUrl(base: string, ...segments: any[]): string; | ||
@@ -5,0 +8,0 @@ export declare class RestRequestBuilder { |
@@ -16,7 +16,9 @@ "use strict"; | ||
var cleanupRegex = /\/+$/g; | ||
var jsonContentType = "application/json,text/json"; | ||
function appendAcceptJsonHeader(params) { | ||
return __assign(__assign({}, params), { headers: __assign(__assign({}, (params || {}).headers), { Accept: jsonContentType }) }); | ||
exports.ContentTypes = { | ||
json: "application/json,text/json", | ||
}; | ||
function appendAcceptHeader(params, acceptContentType) { | ||
return __assign(__assign({}, params), { headers: __assign(__assign({}, (params || {}).headers), { Accept: acceptContentType }) }); | ||
} | ||
exports.appendAcceptJsonHeader = appendAcceptJsonHeader; | ||
exports.appendAcceptHeader = appendAcceptHeader; | ||
function appendUrl(base) { | ||
@@ -68,3 +70,3 @@ var segments = []; | ||
var requestUrl = this.appendQuery(this.urlValue, queryParams); | ||
var params = appendAcceptJsonHeader(this.params); | ||
var params = appendAcceptHeader(this.params, exports.ContentTypes.json); | ||
return this.apiConnector.get(requestUrl, params).then(function (x) { return x.json(); }); | ||
@@ -77,3 +79,3 @@ }; | ||
RestRequestBuilder.prototype.post = function (content) { | ||
var params = appendAcceptJsonHeader(this.params); | ||
var params = appendAcceptHeader(this.params, exports.ContentTypes.json); | ||
return this.apiConnector.postJson(this.urlValue, content, params).then(function (x) { return x.json(); }); | ||
@@ -88,3 +90,3 @@ }; | ||
RestRequestBuilder.prototype.put = function (content) { | ||
var params = appendAcceptJsonHeader(this.params); | ||
var params = appendAcceptHeader(this.params, exports.ContentTypes.json); | ||
return this.apiConnector.putJson(this.urlValue, content, params).then(function (x) { return x.json(); }); | ||
@@ -99,3 +101,3 @@ }; | ||
RestRequestBuilder.prototype.patch = function (content) { | ||
var params = appendAcceptJsonHeader(this.params); | ||
var params = appendAcceptHeader(this.params, exports.ContentTypes.json); | ||
return this.apiConnector.patchJson(this.urlValue, content, params).then(function (x) { return x.json(); }); | ||
@@ -102,0 +104,0 @@ }; |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "0.16.0-beta.4", | ||
"version": "0.16.0-beta.5", | ||
"description": "Frui.ts helpers for HTTP communication", | ||
@@ -36,6 +36,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@frui.ts/helpers": "^0.16.0-beta.4", | ||
"@frui.ts/helpers": "^0.16.0-beta.5", | ||
"query-string": "^6.9.0" | ||
}, | ||
"gitHead": "9080a2197febdca553302a14ba42f9888ef48878" | ||
"gitHead": "f07b6cb55c7e54f1aa73ca9d29c3935a2e5d0b01" | ||
} |
Sorry, the diff of this file is not supported yet
37922
364