How to use apiFetch to get author information in Gutenberg properly?

Finally, I found out how to do it. Just call fetchApi in componentDidMount and then create a new state in your component and add the response to this state when the request is done: constructor(props) { super(props); this.state = { data: {}, }; } componentDidMount() { apiFetch( { path: ‘/wp/v2/users/1’ } ) .then(data => this.setState({ … Read more

Styles don’t load correctly. Insecure content

__DIR__ returns the current file system path, not a URL. So the resulting stylesheet will not be a valid URL, and will not have https://, causing the insecure content warning. To get the URL for a stylesheet in your plugin, you need to use plugins_url(): wp_register_style( ‘estilo’, plugins_url( ‘assets/css/estilo.css’, __FILE__ ) ); The use of … Read more