Creates a Menu Item
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
menu_item: {
name: 'T-Shirts',
menu_id: 1,
code: 'MEN-TS',
subtitle: 'Shop men\'s T-Shirts',
destination: 'https://getvendo.com',
new_window: true,
item_type: 'Link',
linked_resource_type: 'URL',
linked_resource_id: 1
}
})
};
fetch('http://{defaultHost}/api/v2/platform/menu_items', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "21",
"type": "menu_item",
"attributes": {
"name": "Link no. 18 To Somewhere",
"subtitle": null,
"destination": null,
"new_window": false,
"item_type": "Link",
"linked_resource_type": "Spree::Linkable::Uri",
"code": null,
"lft": 8,
"rgt": 9,
"depth": 1,
"created_at": "2022-11-08T19:34:24.333Z",
"updated_at": "2022-11-08T19:34:24.336Z",
"link": null,
"is_container": false,
"is_root": false,
"is_child": true,
"is_leaf": true
},
"relationships": {
"icon": {
"data": null
},
"menu": {
"data": {
"id": "3",
"type": "menu"
}
},
"parent": {
"data": {
"id": "17",
"type": "menu_item"
}
},
"linked_resource": {
"data": null
},
"children": {
"data": []
}
}
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Show child attributes
Record created
Show child attributes
Was this page helpful?
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
menu_item: {
name: 'T-Shirts',
menu_id: 1,
code: 'MEN-TS',
subtitle: 'Shop men\'s T-Shirts',
destination: 'https://getvendo.com',
new_window: true,
item_type: 'Link',
linked_resource_type: 'URL',
linked_resource_id: 1
}
})
};
fetch('http://{defaultHost}/api/v2/platform/menu_items', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "21",
"type": "menu_item",
"attributes": {
"name": "Link no. 18 To Somewhere",
"subtitle": null,
"destination": null,
"new_window": false,
"item_type": "Link",
"linked_resource_type": "Spree::Linkable::Uri",
"code": null,
"lft": 8,
"rgt": 9,
"depth": 1,
"created_at": "2022-11-08T19:34:24.333Z",
"updated_at": "2022-11-08T19:34:24.336Z",
"link": null,
"is_container": false,
"is_root": false,
"is_child": true,
"is_leaf": true
},
"relationships": {
"icon": {
"data": null
},
"menu": {
"data": {
"id": "3",
"type": "menu"
}
},
"parent": {
"data": {
"id": "17",
"type": "menu_item"
}
},
"linked_resource": {
"data": null
},
"children": {
"data": []
}
}
}
}