I have a route with /coordinates. I want to receive a JSON Array on this route, such as:
[
{"latitude": 1, "longitude": 1},
{"latitude": 1, "longitude": 2},
{"latitude": 1, "longitude": 3}
]
How do I configure the params to parse this kind of data with grape? I don't want to give a name to the array such as { "blah": []}
, I just want to read it from the request.
Here's what I'm trying to do
params do
requires :latitude, type: Float
requires :longitude, type: Float
end
post do
route = Route.create(coordinates: params)
{ id: route.id }
end