From ca09aa0fd55719abf43387becf5199a56623cf84 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Mon, 16 Aug 2021 16:47:15 +0200 Subject: [PATCH] Implemented basic api getting and deletion --- package.json | 3 +- src/lib/Apiclient.js | 18 ++++++++ src/routes/links.svelte | 92 +++++++++++++++++++++++------------------ 3 files changed, 72 insertions(+), 41 deletions(-) create mode 100644 src/lib/Apiclient.js diff --git a/package.json b/package.json index be34959..a8bd6e1 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ }, "type": "module", "dependencies": { - "@sveltejs/adapter-static": "^1.0.0-next.16" + "@sveltejs/adapter-static": "^1.0.0-next.16", + "axios": "^0.21.1" } } diff --git a/src/lib/Apiclient.js b/src/lib/Apiclient.js new file mode 100644 index 0000000..3f9b6ee --- /dev/null +++ b/src/lib/Apiclient.js @@ -0,0 +1,18 @@ +import axios from 'axios'; +const config = { + username: "niggl", + password: "9VEBc596T7tiPB7mNJukfeH9LfGzrrJN" +} +export default class Apiclient { + static async getUrls() { + return (await axios.get("https://kauft.es/api?showVisits=true", { + auth: config + })).data + } + + static async deleteUrl(shortcode) { + return (await axios.delete(`https://kauft.es/api/${shortcode}`, { + auth: config + })).status + } +} \ No newline at end of file diff --git a/src/routes/links.svelte b/src/routes/links.svelte index 6884949..e2356d4 100644 --- a/src/routes/links.svelte +++ b/src/routes/links.svelte @@ -1,46 +1,58 @@

Manage all links

- - - - - - - - - - - - - - - - - -
- Shortcode - - Target - - Visits - - Edit -
TODO - https://sthsth - 69 - Delete -
+ + + + + + + + + + + {#each urls as url} + + + + + + + {/each} + +
+ Shortcode + + Target + + Visits + + Edit +
+ {url.shortcode} + + {url.target} + {url.visits} + +