Choose your language:
    Update a menu item
    Parameters
    label  string  Optional

    The label of the menu item

    externalUrl  null, string  Optional

    The URL to which the menu item points to

    position  integer  Optional

    Ordering index

    openInNewTab  boolean  Optional

    Opens link in new tab (used together with external_url)

    itemType  item_type.id, null  Optional

    item type associated with the menu item

    parent  null, menu_item.id  Optional

    Parent menu item

    Returns
    Returns a menu_item object.

    Examples

    Example code:
    const { SiteClient } = require('datocms-client');
    async function run() {
    const client = new SiteClient('YOUR-API-TOKEN');
    const menuItemId = '34';
    const menuItem = await client.menuItem.update(menuItemId, {
    label: 'Posts',
    externalUrl: '',
    position: 1,
    openInNewTab: true,
    itemType: '44',
    parent: null
    });
    console.log(menuItem);
    }
    run();
    Returned output:
    > node example.js
    {
    "id": "34",
    "label": "Posts",
    "externalUrl": "",
    "position": 1,
    "openInNewTab": true,
    "itemType": "44",
    "parent": null,
    "children": [
    "34"
    ]
    }