summaryrefslogtreecommitdiff
path: root/examples/non-html-pages/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/non-html-pages/src')
-rw-r--r--examples/non-html-pages/src/pages/company.json.ts9
-rw-r--r--examples/non-html-pages/src/pages/index.astro16
2 files changed, 25 insertions, 0 deletions
diff --git a/examples/non-html-pages/src/pages/company.json.ts b/examples/non-html-pages/src/pages/company.json.ts
new file mode 100644
index 000000000..ecff4458e
--- /dev/null
+++ b/examples/non-html-pages/src/pages/company.json.ts
@@ -0,0 +1,9 @@
+export async function get() {
+ return {
+ body: JSON.stringify({
+ name: 'Astro',
+ url: 'https://astro.build/',
+ }),
+ };
+}
+
diff --git a/examples/non-html-pages/src/pages/index.astro b/examples/non-html-pages/src/pages/index.astro
new file mode 100644
index 000000000..af1ed4326
--- /dev/null
+++ b/examples/non-html-pages/src/pages/index.astro
@@ -0,0 +1,16 @@
+---
+const url = `${Astro.request.canonicalURL.origin}/company.json`;
+const response = await fetch(url);
+const data = await response.json();
+---
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width" />
+ <title>Astro</title>
+ </head>
+ <body>
+ <h1>Astro</h1>
+ <div>{JSON.stringify(data)}</div>
+ </body>
+</html>