hi,
when I issue a simple request like this:
my $login = $ua->post($url_com);
Checking the response is simple:
if ( my $res = $login->success ) {
....
}
else {
my $err = $login->error;
die "$err->{code} response: $err->{message}" if $err->{code};
}
But how to do it when using a more complex request and saving the json data directly in the variable $sections (really cool that this is possible):
my $sections = $ua->get( "https://$url$api/sections/" => { 'token' => $token } )->res->json('/data');
if ( my $sections->success ) {
return $sections;
}
else {
my $err = $sections->error;
die "$err->{code} response: $err->{message}" if $err->{code};
}
I cannot use $sections->success :
Can't call method "success" on an undefined value at
script.pl line ...
I am probably asking something very simple, my apologies for that, but the answer escapes me so far.
Thanks in advance.
--
regards,
Natxo