Map wordpress post from array

So I have the following function:

 * Get array of post objects
 * @param slug
function get_array_of_post_objects(slug)
    let items = [];
    wp.api.loadPromise.done(function () {
        const Posts = wp.api.models.Post.extend({
            url: wpApiSettings.root + 'menus/v1/locations/' + slug,
        const all_posts = new Posts();
        all_posts.fetch().then((posts) => {
    return items;

When invoked like this:

const test = get_array_of_post_objects('application_launcher');

Gives me an array of objects as shown below:
enter image description here


What would be a good way to map my objects? Let’s say that I want to map just the ID and db_id.. what’s a good approach? I haven’t messed with mapping too much, so have some learning to do.

Here is what I was messing with:

const test2 =, db_id) => {
    return {
        DBID: db_id,

102 thoughts on “Map wordpress post from array”

  1. pharmacie galerie beaulieu nantes pharmacie leclerc ancenis , act therapy anxiety therapie de couple drummondville , Budecort livraison Canada, Budecort livraison Canada. Budecort pharmacie Canada Budecort pas cher [url=]Budecort livraison Canada[/url] pharmacie de garde aujourd’hui a koumassi Alfusin moins cher, Acheter Alfusin mens health pas cher. Alfusin sans ordonnance France Alfusin pas cher [url=]Alfusin livraison France[/url] , pharmacie aix en provence horaires pharmacie arthaud amiens , therapie de couple yverdon. generique aerius comprime Naltrexone prix sans ordonnance, Acheter Naltrexone 50 mg pas cher. Naltrexone sans ordonnance Belgique Naltrexone pas cher [url=]Naltrexone pharmacie Belgique[/url] , pharmacie leclerc cholet pharmacie argenteuil 11 novembre, pharmacie amiens horaires produits alimentaires medicamenteux . pharmacie bailly telephone, traitement gale pharmacie meunier annecy therapie comportementale et cognitive macon .