summaryrefslogtreecommitdiff
path: root/src/clients
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients')
-rw-r--r--src/clients/loaders.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/clients/loaders.ts b/src/clients/loaders.ts
index f3d01cc..ffb44f3 100644
--- a/src/clients/loaders.ts
+++ b/src/clients/loaders.ts
@@ -3,6 +3,7 @@ import { ApiClient } from "./api_client";
import { Product, mapProduct } from "../models/product";
import { Card } from "../models/card";
import { refreshIfExpired, logout, presentSession } from "../lib/session";
+import { deleteEmptyParams } from "../lib/form_utils";
import Token from "../lib/token";
import Order from "../models/order";
@@ -17,7 +18,8 @@ export async function loader({ request }) {
const client = new ApiClient();
const url = new URL(request.url)
- const response = await client.get(`${url.pathname}${url.search}`);
+ const params = '?' + deleteEmptyParams(new URLSearchParams(url.search)).toString();
+ const response = await client.get(`${url.pathname}${params}`);
return response;
}
@@ -87,6 +89,13 @@ export async function accountLoader() {
export async function productLoader({ params }) {
const client = new ApiClient();
const response = await client.getProduct(params.productId);
+
+ if(response[0].response?.status == 404) {
+ throw new Response("", {
+ status: 404,
+ statusText: "El producto que desea buscar no existe",
+ });
+ }
return [response[0], response[1]];
}