I'm working on my first wordpress custom theme and working on a custom Gutenberg block. So far it works on my setup. But worried about when users will be installing it on different paths. I'm making a REST API call like this: function( props ) { if (! props.attributes.categories ){ wp.apiFetch( { url: '/wordpress/wp-json/wp/v2/categories' } ).then(categories => { props.setAttributes ({ categories: categories }) }); } I've installed wordpress locally with MAMP on a custom path (/wordpress) instead of the main folder. So http://localhost/wordpress/ . My question is, the API URL url: '/wordpress/wp-json/wp/v2/categories' works because I've specified the exact path, adding /wordpress/ in front of the usual path, but how can I make it dynamic so that it works for whatever path users install their wordpress site to? Doing just url: '/wp-json/wp/v2/categories'
A site where you can share knowledge