Show examples in:
    List all fields

    Returns

    Returns an array of field resource objects.

    Examples

    Example code:
    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.list(modelIdOrApiKey);
    fields.forEach((field) => {
    console.log(field);
    });
    }
    run();
    Returned output:
    {
    id: '124',
    label: 'Title',
    field_type: 'string',
    localized: true,
    default_value: {
    en: 'A default value',
    it: 'Un valore di default'
    },
    api_key: 'title',
    hint: 'This field will be used as post title',
    validators: {
    required: {}
    },
    appearance: {
    editor: 'single_line',
    parameters: {
    heading: false
    },
    addons: [
    {
    id: '1234',
    field_extension: 'lorem_ipsum',
    parameters: {}
    }
    ]
    },
    position: 1,
    item_type: {
    type: 'item_type',
    id: '44'
    },
    fieldset: null
    }