<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 24, 2015 at 11:55 AM, Andrew Beverley <span dir="ltr"><<a href="mailto:andy@andybev.com" target="_blank">andy@andybev.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">On Mon, 2015-08-24 at 11:31 +0300, Gabor Szabo wrote:<br>
> When I use Angular to send a POST request to the Dancer back-end, by<br>
> default it send<br>
><br>
> 'CONTENT_TYPE' => 'application/json;charset=UTF-8',<br>
><br>
> and the data looks like this:<br>
><br>
> 'body' => '{"foo":23,"bar":19}',<br>
><br>
> and Dancer2 does not parse this.<br>
<br>
</span>I think a serializer should do what you want, but you need to explicitly enable<br>
one:<br>
<br>
<a href="https://metacpan.org/pod/Dancer2::Manual#Serializers1" rel="noreferrer" target="_blank">https://metacpan.org/pod/Dancer2::Manual#Serializers1</a><br>
<br>
Andy<br>
<br></blockquote><div><br><br>I have just tried to set<br><br>   set serializer => 'JSON';<br></div><div><br></div><div>that caused another issue. Now when I return the main page which is plain HTML, I get an error<br><br> Failed to serialize the request: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /Users/gabor/perl5/perlbrew/perls/perl-5.22.0_WITH_THREADS/lib/site_perl/5.22.0/JSON.pm line 154. in (eval 153) l. 1<br><br></div><div>and I don't get the page back.<br><br></div><div>Then I tried to trick it and loaded the HTML page before enabling the serializer, then switch it on, let the server restart and sent the<br></div><div>Ajax POST request. That worked, but I am now with the problem of displaying the initial HTML page.<br></div><div>Reading the docs you linked to I thought it should just send out the plain HTML page as it is a plain scalar. I am not sure why does it fail.<br></div><div><br></div>Gabor<br><br></div><div class="gmail_quote"><div><br></div></div></div></div>