title: Render Grape API to string from a view
body: <p>I have <strong>Grape based API</strong> set up in a Rails 4 app. I want to <strong>render the json produced</strong> by one of the API calls into a view in an <strong>inline  tag</strong> - specifically to make JSON data available to an angularjs view to avoid a (JSON API) call to server after page load.</p>
  
  <p>Any ideas how to get a <strong>Grape API rendered to string</strong>?</p>
  
  <p><em>/app/api/api.rb</em></p>
  
  <pre><code>class API &lt; Grape::API
    version 'v1', using: :path
    format :json
    get '/dashboard' do
      ...
    end
  end
  </code></pre>
  
  <p><em>views/dashboard/index.html.erb</em></p>
  
  <pre><code>&lt;script&gt;   
    &lt;%= render some-way-to-render-to-text('/api/v1/dashboard.json') %&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>I could use a get http request to get it rendered, but I am hoping to avoid the overhead of the http call. I rather call the API class directly.</p>