How do I run an action after a featured image has been selected in the Gutenberg editor?

All current data from the Block Editor is stored in a data store. If you click on the save button, this data is send via the REST API to the database.
You can select data from the store and subscribe to changes.

// Create a higher-order component that updates automatically when featured image changes.
const applyWithSelect = withSelect( ( select ) => {
    const { getMedia } = select( 'core' );
    const { getEditedPostAttribute } = select( 'core/editor' );
    const featuredImageId = getEditedPostAttribute( 'featured_media' );

    return {
        media: featuredImageId ? getMedia( featuredImageId ) : null,
        featuredImageId,
    };
} );

export default compose( [
    applyWithSelect,
] )( MyCustomBlockEdit );

source

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)