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.

Revisions

  1. chsanch created this gist Jun 5, 2018.
    22 changes: 22 additions & 0 deletions test-cro.p6
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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;
    }