π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
handle fields array
Fendy Heryanto504038f6a9c8
diff --git a/packages/nocodb/src/helpers/PagedResponse.ts b/packages/nocodb/src/helpers/PagedResponse.tsindex 0c01c7531a..7040ff27d9 100644--- a/packages/nocodb/src/helpers/PagedResponse.ts+++ b/packages/nocodb/src/helpers/PagedResponse.ts@@ -3,6 +3,30 @@ import type { NcContext, PaginatedType, PaginatedV3Type } from 'nocodb-sdk';import { NcError } from '~/helpers/catchError';import { extractProps } from '~/helpers/extractProps';+type SearchParamValue = string | number | boolean | null | undefined;+type SearchParamsObject = {+ [key: string]: SearchParamValue | SearchParamValue[];+};++// handle fields[] in array format+function objectToSearchParams(obj: SearchParamsObject): URLSearchParams {+ const params = new URLSearchParams();++ Object.entries(obj).forEach(([key, value]) => {+ if (Array.isArray(value)) {+ value.forEach((item) => {+ if (item !== null && item !== undefined) {+ params.append(key, String(item));+ }+ });+ } else if (value !== null && value !== undefined) {+ params.append(key, String(value));+ }+ });++ return params;+}+// a utility function which accept baseUrl, path and query params and constructs a urlexport function constructUrl({baseUrl,@@ -15,7 +39,7 @@ export function constructUrl({}) {let url = `${baseUrl}${path}`;if (query) {- const queryStr = new URLSearchParams(query).toString();+ const queryStr = objectToSearchParams(query).toString();url = `${url}?${queryStr}`;}return url;