summaryrefslogtreecommitdiff
path: root/client/client.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/client.js')
-rw-r--r--client/client.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/client/client.js b/client/client.js
index 451358e..ee50373 100644
--- a/client/client.js
+++ b/client/client.js
@@ -1,10 +1,17 @@
-function _get(data) {
+function _get_url(_url, data) {
+ const url = new URL(document.origin + _url)
+ console.log(_url, data, document.origin)
+ if (data) {
+ Object.keys(data).forEach(key => url.searchParams.append(key, data[key]))
+ }
+ return url
+}
+function _get_headers() {
return {
method: 'GET',
headers: {
'Accept': 'application/json',
},
- query: data,
}
}
function post(data) {
@@ -53,7 +60,7 @@ function crud(type_s) {
const type = '/' + type_s + 's/'
return {
index: (data) => {
- return fetch(type, _get(data))
+ return fetch(_get_url(type, data), _get_headers())
.then(req => req.json())
.catch(error)
},