Skip to main content

useFetchEntityByForeignId

Overview

The useFetchEntityByForeignId hook is used to retrieve details of a specific entity by providing its foreignId. This hook can optionally create a new entity if one wasn’t found.

Usage Example

Parameters & Returns

Parameters

The hook returns a function that accepts an object with the following fields:
foreignId
string
required
The foreign ID of the entity to fetch.
createIfNotFound
boolean
Whether a new entity should be created with this foreign ID if one wasn’t found.

Returns

The function resolves with an object representing the fetched entity:
Entity
object
The details of the retrieved entity.