I have Grape based API set up in a Rails 4 app. I want to render the json produced by one of the API calls into a view in an inline tag - specifically to make JSON data available to an angularjs view to avoid a (JSON API) call to server after page load.
Any ideas how to get a Grape API rendered to string?
/app/api/api.rb
class API < Grape::API
version 'v1', using: :path
format :json
get '/dashboard' do
...
end
end
views/dashboard/index.html.erb
<script>
<%= render some-way-to-render-to-text('/api/v1/dashboard.json') %>
</script>
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.