From c7e493ce3d2855e61787d86714625bc7fc51f9bd Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Wed, 26 Apr 2023 21:37:38 -0600 Subject: AƱade vista de producto individual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clients/loaders.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/clients/loaders.ts (limited to 'src/clients/loaders.ts') diff --git a/src/clients/loaders.ts b/src/clients/loaders.ts new file mode 100644 index 0000000..43c1581 --- /dev/null +++ b/src/clients/loaders.ts @@ -0,0 +1,16 @@ +import { ApiClient } from "./api_client"; + +export async function loader({ request }) { + const client = new ApiClient(); + const url = new URL(request.url) + const response = await client.get(url.pathname); + + return response; +} + +export async function productLoader({ params }) { + const client = new ApiClient(); + const response = await client.getProduct(params.productId); + + return [response[0], response[1]]; +} \ No newline at end of file -- cgit v1.2.3