planning-center-monorepo v1.0.0
planning-center-monorepo / planning-center-people-ts/src / resolveIncluded
Function: resolveIncluded()
resolveIncluded<
T>(included,relationshipData):T[]
Defined in: packages/planning-center-people-ts/src/helpers.ts:926
Resolve all resources from a relationship to their full included objects
Takes a relationship’s data array (which contains resource identifiers) and resolves them to full resource objects 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
relationshipData
Relationship data array (from relationships.xxx.data)
ResourceIdentifier<string> | ResourceIdentifier<string>[]
Returns
T[]
Array of full resource objects, or empty array if none found
Example
const person = await client.people.getPage({ include: ['emails', 'phone_numbers'] });
// Data is flattened: person.data[0].emails is the resolved array
const emails = person.data[0].emails ?? [];
emails.forEach(email => console.log(email.address));