diff --git a/package.json b/package.json index 4b43373f..96bbe34c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@charmverse/core", - "version": "0.3.15", + "version": "0.3.16-rc-fix-get-request.0", "description": "Core API for Charmverse", "type": "commonjs", "types": "./dist/cjs/index.d.ts", diff --git a/src/lib/http/index.ts b/src/lib/http/index.ts index 92a5459f..5af11df1 100644 --- a/src/lib/http/index.ts +++ b/src/lib/http/index.ts @@ -5,9 +5,13 @@ type Params = { [key: string]: any }; export function GET( _requestUrl: string, data: Params | null | undefined, - { headers = {}, credentials = 'include' }: { credentials?: RequestCredentials; headers?: any } = {} + { + headers = {}, + credentials = 'include', + addBracketsToArrayValues + }: { credentials?: RequestCredentials; headers?: any; addBracketsToArrayValues?: boolean } = {} ): Promise { - const requestUrl = _appendQuery(_requestUrl, data || {}); + const requestUrl = _appendQuery(_requestUrl, data || {}, addBracketsToArrayValues); return fetch(requestUrl, { method: 'GET', headers: new Headers({ @@ -69,13 +73,13 @@ export function PUT(requestURL: string, data: Params = {}, { headers = {} }: }); } -function _appendQuery(path: string, data: Params) { +function _appendQuery(path: string, data: Params, addBracketsToArrayValues: boolean = true) { const queryString = Object.keys(data) .filter((key) => !!data[key]) .map((key) => { const value = data[key]; return Array.isArray(value) - ? `${value.map((v: string) => `${key}[]=${v}`).join('&')}` + ? `${value.map((v: string) => `${key}${addBracketsToArrayValues ? '[]' : ''}=${v}`).join('&')}` : `${key}=${encodeURIComponent(value)}`; }) .join('&'); diff --git a/src/lib/permissions/pages/client/pagePermissionsHttpClient.ts b/src/lib/permissions/pages/client/pagePermissionsHttpClient.ts index 0a962112..350df0ee 100644 --- a/src/lib/permissions/pages/client/pagePermissionsHttpClient.ts +++ b/src/lib/permissions/pages/client/pagePermissionsHttpClient.ts @@ -39,7 +39,9 @@ export class PagePermissionsHttpClient extends AbstractPermissionsApiClient impl ); const computedResult = await asyncSeries(chunkedPageIds, (chunkedRequest: BulkPagePermissionCompute) => - GET(`${this.prefix}/bulk-compute-page-permissions`, chunkedRequest) + GET(`${this.prefix}/bulk-compute-page-permissions`, chunkedRequest, { + addBracketsToArrayValues: false + }) ).then((results) => { const mergedResults: BulkPagePermissionFlags = {};