How can I get post-id & user in showModal controller?

This is my initializer below:

export default {
    name: 'customInit',
    initialize() {      
        withPluginApi('0.8.7', api => {             
            api.attachWidgetAction('post', 'showCustomModal', () => {
                const modal = showModal('customModal');
            });
                
            api.addPostMenuButton('customBtn', (attrs) => {                
                return {
                    data: {
                        "post-id": attrs.id,
                        "user": attrs.username
                    },
                    action: 'showCustomModal',
                    icon: 'hand-holding-usd',
                    className: 'custom-btn',
                    title: 'custom_icon_anchor',
                    position: 'first' 
                };
            });
        });
    }
};

It shows my modal correctly, but I’m wondering how I can pass my post-id and user depending on which custom post menu button was clicked. I’ve been searching through Github for hours now and I still can’t seem to understand how I could possibly pass this to my Custom Modal Controller.

2 Likes