diff options
Diffstat (limited to 'src/mixins.ts')
| -rw-r--r-- | src/mixins.ts | 47 |
1 files changed, 47 insertions, 0 deletions
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<void> { + 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<void> { + fetch('http://localhost/api/v1/languages', { + method: 'GET', + }) + .then((response) => response.json()) + .then((response) => { + this.languages = response; + this.isLoading = false; + }); + } + + async fetchRandom(): Promise<void> { + fetch('http://localhost/api/v1/random', { + method: 'GET', + }) + .then((response) => response.json()) + .then((response) => { + this.random = response; + this.isLoading = false; + }); + } +} |