From 39d2fcc94ccd73db489590e1c327a6b34e0e73a3 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 6 May 2021 20:20:37 +0000 Subject: feat(global): :star: --- src/mixins.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/mixins.ts (limited to 'src/mixins.ts') diff --git a/src/mixins.ts b/src/mixins.ts new file mode 100644 index 0000000..bea2fca --- /dev/null +++ b/src/mixins.ts @@ -0,0 +1,47 @@ +import { Options, Vue } from 'vue-class-component'; + +@Options({}) +export default class APIExtendableLanguage extends Vue { + isLoading = true; + + images: any; + + language = ''; + + languages: any; + + random: any; + + async fetchImages(): Promise { + fetch(`http://localhost/api/v1/language?lang=${this.language}`, { + method: 'GET', + }) + .then((response) => response.json()) + .then((response) => { + this.images = response; + this.isLoading = false; + }); + } + + async fetchLanguages(): Promise { + fetch('http://localhost/api/v1/languages', { + method: 'GET', + }) + .then((response) => response.json()) + .then((response) => { + this.languages = response; + this.isLoading = false; + }); + } + + async fetchRandom(): Promise { + fetch('http://localhost/api/v1/random', { + method: 'GET', + }) + .then((response) => response.json()) + .then((response) => { + this.random = response; + this.isLoading = false; + }); + } +} -- cgit v1.2.3