Skip to Content
APIPlanning Center People TSSrcFunctionsFunction: findIncluded()

planning-center-monorepo v1.0.0


planning-center-monorepo / planning-center-people-ts/src / findIncluded

Function: findIncluded()

findIncluded<T>(included, type, id): T

Defined in: packages/planning-center-people-ts/src/helpers.ts:895 

Find an included resource by type and id

In JSON:API, relationships contain resource identifiers like { type: ‘Email’, id: ‘456’ } This helper finds the full resource object from the included array.

Type Parameters

T

T extends ResourceObject<string, any, any> = ResourceObject<string, any, any>

Parameters

included

ResourceObject<string, any, any>[]

Array of included resources from JSON:API response

type

string

Resource type to find

id

string

Resource id to find

Returns

T

The matching resource object, or undefined if not found

Example

const person = await client.people.getPage({ include: ['emails'] }); // Data is flattened: person.data[0].emails is the resolved array const email = person.data[0].emails?.[0]; console.log(email?.address); // 'john@gmail.com'