Show examples in:
List referenced fields

Returns all fields in the project that reference a specific model (works both for Models and Block Models)

Returns

Returns an array of field resource objects.

Examples

Example Basic example
import { buildClient } from '@datocms/cma-client-node';
async function run() {
const client = buildClient({ apiToken: '<YOUR_API_TOKEN>' });
const modelIdOrApiKey = 'blog_post';
const fields = await client.fields.referencing(modelIdOrApiKey);
fields.forEach((field) => {
console.log(field);
});
}
run();