- gif search

- added models to parse the tenor-api-response correctly
- continued with designing the main chat-page
This commit is contained in:
joschuatonn
2024-05-04 19:03:24 +02:00
parent ef105ded6d
commit 1876482e5e
7 changed files with 482 additions and 119 deletions

26
src/stores/tenor-store.ts Normal file
View File

@@ -0,0 +1,26 @@
import { defineStore } from 'pinia';
import {api} from 'boot/axios';
import { ptpUser, responseModel, tenorResponseElement } from 'src/models';
import Keycloak from 'keycloak-js';
export const useTenorStore = defineStore('tenorStore', {
state: () => ({
gifs: [] as Array<tenorResponseElement>,
gifsLoaded: false,
}),
getters: {
},
actions: {
getGifsBySearchTerm(searchTerm : string) {
this.loadGifsBySearchTerm(searchTerm).then((response : any) => {
this.gifs = response.data.results;
this.gifsLoaded = true;
console.log(this.gifsLoaded + " / from store");
});
},
async loadGifsBySearchTerm(searchTerm : string) : Promise<any> {
return await api.get("https://tenor.googleapis.com/v2/search?q="+searchTerm+"&key=AIzaSyBXsUPCjnmjXwcdqMLsyhrH1zm_6VYH_fY&client_key=praxistransferProjekt&limit=10");
}
},
});