How to grab posts in Gutenberg Block?

You’ll need to use the REST API. You can access the latest posts by calling:

wp.apiFetch( { path: '/wp/v2/posts' } ).then( posts => {
    console.log( posts );
} );

Here is some more information on using the package – https://developer.wordpress.org/block-editor/packages/packages-api-fetch/

error code: 523