So I have the following code:
function get_menu_location($id)
{
const menu = wp.api.collections.Posts.extend({
url: wpApiSettings.root + 'menus/v1/menus/' + $id,
});
const Menu = new menu();
Location.fetch().then((posts) => {
console.log(posts.items);
return posts.items;
});
}
document.getElementById("menu_id").innerHTML = get_menu($id);
When I call: get_menu(4)
alone, I get the following console output:
This is the error that I'm getting:
How would I be able to pull in that data to my <div id="menu_4"></div>
and output the results inside HTML?