title: How to get the site root URL when using Wordpress gutenberg wp object
body: <p>I just created my first gutenberg block plugin using the npm package <code>create-guten-block</code>.</p>
  
  <p>The edit function looks like the code you see below. But it gives a 404 not found on the <code>apiFetch()</code> call because the website lives in a folder, not in the root of the domain. In other words: The structure of the hostname is <code>http://localhost/websitename/</code> not <code>websitename.local</code>.</p>
  
  <pre><code>edit: ( props ) =&gt; {
      if ( ! props.attributes.categories ) {
          wp.apiFetch( {
             url: '/wp-json/wp/v2/categories'
          }).then(categories =&gt; {
              props.setAttributes( {
                  categories: categories
              });
          });
      }
      return (
          true
      );
  }
  </code></pre>
  
  <p>So what would be the equivalent to PHP's <code>get_site_url()</code>? Is that data somewhere stored in the <code>wp</code> object? If so, where? Because I need to prepend <code>/wp-json/wp/v2/categories</code> with the right site URL.</p>