i am new to Perl and Mojo and i've got one problem by receiving POST-Data from Angular:
My AngularCode is
var datainput = JSON.stringify({"test":"orcl"});
$http.post('http://localhost/perltest/perltest.pl/post', datainput)
.success(function(data, status, headers, config) {
console.log("post geschickt");
console.log(headers());
console.log(data);
console.log("data back: " + JSON.stringify(data));
alert(JSON.stringify(data));
})
My Mojo-Sub looks like:
post '/post' => sub {
my $self = shift;
my $json = $self->req->json;
print header(-type => "text/html");
print Dumper($json->{test});
};
app->start;
The Result i get is: $VAR1 = undef; Content-Length: 0 Status: 404 Not Found Date: Fri, 20 Jan 2017 09:49:57 GMT
What is wrong? It seems to me that $json = $self->req->json is not getting the JSON-String from POST ?