- gif search
- added models to parse the tenor-api-response correctly - continued with designing the main chat-page
This commit is contained in:
26
src/stores/tenor-store.ts
Normal file
26
src/stores/tenor-store.ts
Normal 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");
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user