Skip to content

Commit

Permalink
Use new /search/first API endpoint
Browse files Browse the repository at this point in the history
Simplify data reading using the new endpoint.
  • Loading branch information
mickeyn committed Jul 11, 2017
1 parent 8ccb288 commit 5a61b2f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/MetaCPAN/Web/Model/API/Module.pm
Expand Up @@ -49,12 +49,11 @@ sub search_web {

sub first {
my ( $self, $query ) = @_;
$self->request( "/search/simple", undef, { q => $query } )->transform(
$self->request( "/search/first", undef, { q => $query } )->transform(
done => sub {
my $data = shift;
return undef
unless ( $data->{hits}->{total} );
return $data->{hits}->{hits}->[0]->{fields}->{documentation};
return unless $data;
return $data->{documentation};
}
);
}
Expand Down

0 comments on commit 5a61b2f

Please sign in to comment.