External Data Integration (infuseData)
TheinfuseData
callback allows you to merge external data with entities fetched by Replyke. This is useful when your entities need additional information from external APIs or databases.
How It Works
When you provide aninfuseData
function to useEntityList
, it:
- Receives the
foreignId
of each entity - Fetches additional data from your external source
- Adds the external data under an
infusion
property - Returns the combined data in the
infusedEntities
array
entities
array remains unchanged, containing only Replyke’s data. External data is safely nested under the infusion
property to prevent key conflicts.
Usage
Performance
- Data is fetched once per entity and cached
- Failed fetches return
null
and don’t block other entities - The
infuseData
function is called automatically when new entities are loaded
Use Cases
Product Inventory
User Profiles
Analytics Data
Error Handling
TheinfuseData
function should handle errors gracefully:
Data Structure
External data is safely nested under theinfusion
property to prevent conflicts with Replyke’s entity properties:
Accessing Infused Data
Always access external data through theinfusion
property: