Skip to Content
APIPlanning Center Base TSSrcFunctionsFunction: buildQueryParams()

planning-center-monorepo v1.0.0


planning-center-monorepo / planning-center-base-ts/src / buildQueryParams

Function: buildQueryParams()

buildQueryParams(params?): Record<string, string | number | boolean | undefined>

Defined in: packages/planning-center-base-ts/src/query-params.ts:35 

Transform complex params object into flat query params for API calls Supports both typed where clauses and generic Record types

Parameters

params?

Query parameters including where clause, include, pagination, and ordering

where?

Record<string, string | number | boolean | undefined>

include?

string[]

per_page?

number

page?

number

order?

string

Returns

Record<string, string | number | boolean | undefined>

Flat object with query parameters ready for URL encoding

Example

const params = buildQueryParams({ where: { status: 'active', first_name: 'John' }, include: ['emails', 'phone_numbers'], per_page: 25, page: 1, order: 'first_name' }); // Returns: { // 'where[status]': 'active', // 'where[first_name]': 'John', // include: 'emails,phone_numbers', // per_page: 25, // offset: 0, // page: 1, // order: 'first_name' // }