summaryrefslogtreecommitdiff
path: root/src/clients
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-23 13:12:25 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-23 13:12:25 -0600
commit31cc5ecdb693be1da04ee0a3e6dc876535d5fb4b (patch)
treec87dc3b5aea7b791e7cef8984c1e0a2f31b58418 /src/clients
parent9a5b4259808d719a531eca18dff993eeeff71bc1 (diff)
Añade loader
Diffstat (limited to 'src/clients')
-rw-r--r--src/clients/api_client.ts5
-rw-r--r--src/clients/loader.ts8
2 files changed, 11 insertions, 2 deletions
diff --git a/src/clients/api_client.ts b/src/clients/api_client.ts
index f2bcd35..a7b5e0d 100644
--- a/src/clients/api_client.ts
+++ b/src/clients/api_client.ts
@@ -1,16 +1,17 @@
import axios from "axios";
export class ApiClient {
- readonly url = "http://localhost:5000/api";
+ readonly url = "http://localhost:3000/api";
async get(path: string) {
const request_url = `${ this.url }${ path }`;
try {
const response = await axios.get(request_url);
+
return response;
} catch(error) {
- console.log(error);
+ return error.response;
}
}
} \ No newline at end of file
diff --git a/src/clients/loader.ts b/src/clients/loader.ts
new file mode 100644
index 0000000..645ba88
--- /dev/null
+++ b/src/clients/loader.ts
@@ -0,0 +1,8 @@
+import { ApiClient } from "./api_client";
+
+export default async function loader(path: string, { params }) {
+ const client = new ApiClient();
+ const response = await client.get(path);
+
+ return response.data;
+} \ No newline at end of file