title: Returning Image from WP REST API
body: <p>I'm trying to use the wp rest api to return a list of posts from a blog, including title, excrpt and featured image. Using the below I can return the title and excerpt but the featured image causes <em>Fatal error: Cannot use object of type stdClass as array</em>. </p>
  
  <p>Can anyone advise on what I'm doing wrong?</p>
  
  <pre><code>$posts = json_decode(file_get_contents('https://wordpressurl/wp-json/wp/v2/posts?_embed'));
  
  foreach ( $posts as $post ) 
  {
      echo '&lt;a href="'.$post-&gt;link.'"&gt;
              &lt;img src="'.$post-&gt;_embedded['wp:featuredmedia']['0'].source_url.'"/&gt; 
              '.$post-&gt;title-&gt;rendered, $post-&gt;excerpt-&gt;rendered.'&lt;/a&gt;';
  };
  </code></pre>