diff options
author | 2022-02-14 17:50:16 +0000 | |
---|---|---|
committer | 2022-02-14 17:50:16 +0000 | |
commit | f84848226d9aa0876a854e5195184925cc793781 (patch) | |
tree | 02238d3ee53d8c7640b1df8d5eb692e341a5a77c /examples/ssr/src/api.ts | |
parent | ba5e2b5e6c20207955991775dc4aa8879331542c (diff) | |
download | astro-f84848226d9aa0876a854e5195184925cc793781.tar.gz astro-f84848226d9aa0876a854e5195184925cc793781.tar.zst astro-f84848226d9aa0876a854e5195184925cc793781.zip |
[ci] yarn format
Diffstat (limited to 'examples/ssr/src/api.ts')
-rw-r--r-- | examples/ssr/src/api.ts | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/examples/ssr/src/api.ts b/examples/ssr/src/api.ts index 9fd7d0683..0ae8648c8 100644 --- a/examples/ssr/src/api.ts +++ b/examples/ssr/src/api.ts @@ -7,13 +7,11 @@ interface Product { //let origin: string; const { mode } = import.meta.env; -const origin = mode === 'develeopment' ? - `http://localhost:3000` : - `http://localhost:8085`; +const origin = mode === 'develeopment' ? `http://localhost:3000` : `http://localhost:8085`; async function get<T>(endpoint: string, cb: (response: Response) => Promise<T>): Promise<T> { const response = await fetch(`${origin}${endpoint}`); - if(!response.ok) { + if (!response.ok) { // TODO make this better... return null; } @@ -21,14 +19,14 @@ async function get<T>(endpoint: string, cb: (response: Response) => Promise<T>): } export async function getProducts(): Promise<Product[]> { - return get<Product[]>('/api/products', async response => { + return get<Product[]>('/api/products', async (response) => { const products: Product[] = await response.json(); return products; }); } export async function getProduct(id: number): Promise<Product> { - return get<Product>(`/api/products/${id}`, async response => { + return get<Product>(`/api/products/${id}`, async (response) => { const product: Product = await response.json(); return product; }); |