Skip to content

Commit

Permalink
Merge pull request #1948 from metacpan/mickey/use_search_first_endpoint
Browse files Browse the repository at this point in the history
Use new /search/first API endpoint
  • Loading branch information
oalders committed Jul 27, 2017
2 parents da961bf + a897a16 commit 66978ae
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 66978ae

Please sign in to comment.