Skip to content

Commit 6785ab9

Browse files
committed
fail silently when fetching version is impossible
1 parent 433162a commit 6785ab9

File tree

1 file changed

+7
-4
lines changed
  • examples/official-site/your-first-sql-website

1 file changed

+7
-4
lines changed

examples/official-site/your-first-sql-website/index.sql

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
SET url = 'https://api.github.com/repos/sqlpage/SQLPage/releases/latest';
2-
SET api_results = sqlpage.fetch($url);
3-
SET sqlpage_version = json_extract($api_results, '$.tag_name');
4-
51
select 'http_header' as component,
62
'public, max-age=300, stale-while-revalidate=3600, stale-if-error=86400' as "Cache-Control",
73
'<https://sql-page.com/your-first-sql-website/>; rel="canonical"' as "Link";
@@ -22,6 +18,13 @@ select 'dynamic' as component, json_patch(json_extract(properties, '$[0]'), json
2218
)) as properties
2319
FROM example WHERE component = 'shell' LIMIT 1;
2420

21+
SET req = '{
22+
"url": "https://api.github.com/repos/sqlpage/SQLPage/releases/latest",
23+
"timeout_ms": 200
24+
}';
25+
SET api_results = sqlpage.fetch_with_meta($req);
26+
SET sqlpage_version = COALESCE(json_extract($api_results, '$.body.tag_name'), '');
27+
2528
SELECT 'hero' as component,
2629
'Your first SQL Website' as title,
2730
'[SQLPage](/) is a free tool for building data-driven apps quickly.

0 commit comments

Comments
 (0)