title: Passing API data to view Laravel
body: <p>I can't figure out why my data is not being passed to View
  I get the message Undefined variable: project </p>
  
  <p>Can someone help identify where i am going wrong? </p>
  
  <p>when i return $project->name straight from the controller it displays the response, however fails to pass to view.</p>
  
  <p>Here is my controller function:</p>
  
  <pre><code>public function getApi(){
  
     $client = new Client();
       $response = $client-&gt;get('https://play.geokey.org.uk/api/projects/77');
  
          $body = $response-&gt;getBody()-&gt;getContents();
           $project = json_decode($body);
  
      return view ('response', compact($project));
  
  
  }
  </code></pre>
  
  <p>And here is my View: </p>
  
  <pre><code>&lt;h1&gt;Welcome&lt;/h1&gt;
  
  &lt;table class="table table-bordered"&gt;
      &lt;tr&gt;
          &lt;th&gt;Project Name&lt;/th&gt;
          &lt;th&gt;Date of Creation&lt;/th&gt;
          &lt;th&gt;Contribution Total&lt;/th&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;td&gt;{{$project-&gt;name}}&lt;/td&gt;
      &lt;/tr&gt;
  
  
  &lt;/table&gt;
  </code></pre>