Returning JSONP or accessing Dreamfactory without a server

I’d like to call dreamfactory endpoints from clientside JS (no webserver) for our internal reporting apps. In other words, allow non-technical users to run the reports on the laptop with no server installed.

Normally you can call dreamfactory using ajax calls, but if you’re running a script from the file:// protocol, modern browsers block all requests, whether or not cors is enabled. The obvious workaround is to use dynamically created <script>s and wrap the response in a variable or function callback (jsonp).

Is there a way to easily configure dreamfactory endpoints to return JSONP? Or do I need to create an endpoint that wraps the response of other endpoints and implement this myself?

Or is there another way to access dreamfactory endpoints without hosting the client files on a server?

Nevermind, I take it back, you can do file:// protocol requests; something else was broken.

$.get('http://[censored[/api/v2/samples/_table/t_[censored]?include_schema=true&api_key=[censored]&filter=([censored])', function(d) {
  console.log(d);
}); 

works fine.

1 Like