In my sinatra app i have a form which is used to submit data via a POST request to a url.The url also accepts json sent in a POST request.
Is there any way to determine in the handler if json data was received in the post or the data submitted was sent from the form ?
Thank You
When you send data via a Post request you will have data in your
paramsHash. So if there is a key there is a value, even if it’s empty. So you can check for example viaparams[:json]if you have received something via json (assuming you call that parameter :json). The same goes for data. But then I’m not entirely sure if that’s what you’re asking for. Either way all data you get is handled via theparamsvariable.