Search code examples
rubyruby-grapegrape-api

Generate JavaScript using the Grape API?


I am using the Grape framework to retrieve data, which is working great. I would also like to retrieve a JavaScript file using the API. For example:

<!DOCTYPE html>
<html>
    <head>
        <script defer src="http://someapi.com/dni_js/dni.js" > </script>
    </head>
    <body>
    </body>
</html>

http://someapi.com/dni_js/dni.js is calling the API.

What would be the best way to accomplish this?


Solution

  • You should implement support for JSONP in your API.

    https://github.com/intridea/grape#jsonp