-
-
Save anquegi/1927155e20c20b846b9d53d105259523 to your computer and use it in GitHub Desktop.
Cro::HTTP::Client example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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