Skip to content

Instantly share code, notes, and snippets.

@anquegi
Forked from chsanch/test-cro.p6
Created September 8, 2022 06:02
Show Gist options
  • Save anquegi/1927155e20c20b846b9d53d105259523 to your computer and use it in GitHub Desktop.
Save anquegi/1927155e20c20b846b9d53d105259523 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