Skip to content

Instantly share code, notes, and snippets.

@chsanch
Created June 5, 2018 15:23
Show Gist options
  • Save chsanch/574ee2eae77f3a811648994b36e24f12 to your computer and use it in GitHub Desktop.
Save chsanch/574ee2eae77f3a811648994b36e24f12 to your computer and use it in GitHub Desktop.
Cro::HTTP::Client example
sub get-term-id ( Cro::HTTP::Client $client, Str $value ) {
my $result;
try {
my $resp = await $client.get: 'terms?short_form=eq.' ~ $value;
# headers => [
# Cro::HTTP::Header.new(
# name => 'Accept',
# value => 'application/vnd.pgrst.object+json'
# )
# ];
$result = await $resp.body;
CATCH {
when X::Cro::HTTP::Error {
say 'Got an error: ' ~ .response.status;
}
}
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment