core.medplumclient.searchresourcepages
Home > @medplum/core > MedplumClient > searchResourcePages
MedplumClient.searchResourcePages() method
Creates an [async generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/AsyncGenerator) over a series of FHIR search requests for paginated search results. Each iteration of the generator yields the array of resources on each page.
Signature:
searchResourcePages<K extends ResourceType>(resourceType: K, query?: QueryTypes, options?: MedplumRequestOptions): AsyncGenerator<ResourceArray<ExtractResource<K>>>;
Parameters
Parameter | Type | Description |
---|---|---|
resourceType | K | The FHIR resource type. |
query | (Optional) Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor. | |
options | (Optional) Optional fetch options. |
Returns:
AsyncGenerator<ResourceArray<ExtractResource<K>>>
Example
for await (const page of medplum.searchResourcePages('Patient', { _count: 10 })) {
for (const patient of page) {
console.log(`Processing Patient resource with ID: ${patient.id}`);
}
}