20 lines
710 B
HTML
20 lines
710 B
HTML
{{ $pbBase := getenv "POCKETBASE_URL" | default site.Params.pocketbase_url }}
|
|
{{ $pbUrl := printf "%s/api/collections/currencies/records" $pbBase }}
|
|
{{ $pbOpts := dict "method" "GET" "timeout" "15s" "headers" (dict "Accept" (slice "application/json")) }}
|
|
{{ $pbCurrencies := slice }}
|
|
{{ $pbOk := false }}
|
|
{{ with try (resources.GetRemote $pbUrl $pbOpts) }}
|
|
{{ with .Err }}
|
|
{{ else with .Value }}
|
|
{{ with transform.Unmarshal .Content }}
|
|
{{ if .items }}
|
|
{{ range $record := .items }}
|
|
{{ $pbCurrencies = $pbCurrencies | append $record.id }}
|
|
{{ end }}
|
|
{{ $pbOk = true }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ return dict "ok" $pbOk "currencies" ($pbCurrencies | append "eur") }}
|