JSON gives you the option to send more straightforward and possibly nested hashes and arrays. JSON body is a relatively common method of making API requests so there's no reason to avoid it really. The only benefit of multipart/form-data is that it's sent natively by HTML forms so doesn't require javascript (or some other language) to construct the request, but that's not really important for an API.
On Sat, Sep 24, 2016 at 2:55 AM, Myf White <[email protected]> wrote: > I'm using a javascript library which has two ways of sending POST requests > > 1. using javascripts FormData, content-type: multipart/form-data > 2. or as JSON within the body, content-type: application/json > > From the Mojolicious side they both work - I can get a parameter 'foo': > > 1. with $c->param('foo') > 2. with $c->req->json->{foo} > > From the javascript side there is no advantage to either way, they both > work as needed. From the Mojolicious side, Is there any advantage to using > either way? > > The system is currently set up just for use by browser, but there is an > idea to develop an API in the future; would that make either of the options > more attractive? > > Any advice on the "right" way to do this would be very much appreciated. > > Kind Regards, > Myf White > > *Email:* [email protected] > > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
