-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSONP breaks presenting Entities #345
Comments
Start by writing a test in Grape that reproduces this. Shouldn't be hard to fix. |
Added further description in Pull: #346 |
JSONP also needs a formatter: formatter :jsonp, lambda { |object, env| object.to_json } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To support JSONP requests I am using Rack::JSONP from the 'rack-jsonp' gem:
However, when this is enabled my GrapEntities don't 'present' properly, the following is what I get:
http://0.0.0.0:9000/v1/cameras/10?callback=abcDef
returns:
abcDef(#<MyAPI::Entities::V1::Camera:0x007f9d5e82f610>)
However
http://0.0.0.0:9000/v1/cameras/10
returns:
The function below illustrates the core of what i'm doing for that route:
Any ideas? I'll keep digging, i'm presuming the issue is the content-type declaration preventing the entity being printed out as JSON. Though I haven't worked my way through Grape's or Grape Entites internals enough yet to be sure.
Cheers,
Gareth
The text was updated successfully, but these errors were encountered: