From 4ce9f89feab70284933eee5335a8cd0d8204e903 Mon Sep 17 00:00:00 2001 From: Syahdan Date: Tue, 10 Jun 2025 11:34:08 +0700 Subject: [PATCH] initial commit with read working --- css/style.css | 7 +++++++ index.html | 32 ++++++++++++++++++++++++++++++++ js/voy.js | 12 ++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 css/style.css create mode 100644 index.html create mode 100644 js/voy.js diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..da9b1b5 --- /dev/null +++ b/css/style.css @@ -0,0 +1,7 @@ +body { + background-color: white; +} + +section#members-table { + width: 50%; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..95e61fd --- /dev/null +++ b/index.html @@ -0,0 +1,32 @@ + + + + + + API Client + + + + + + +
+ + + + + + diff --git a/js/voy.js b/js/voy.js new file mode 100644 index 0000000..95861b9 --- /dev/null +++ b/js/voy.js @@ -0,0 +1,12 @@ +async function voy(url, method, data = null, contentType, authorization) { + const headers = { "Content-Type": contentType }; + if (authorization) headers.Authorization = authorization; + + const body = + data && contentType === "application/json" ? JSON.stringify(data) : data; + + return await fetch(url, { method, headers, body }).then((res) => { + if (!res.ok) throw new Error(`HTTP ${res.status}`); + return res.json(); + }); +}