github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/frontend/bv/src/pages/vote/personne/controller.ts (about) 1 import { BaseController, adjustUrlOrigin } from "@/shared/logic/controller"; 2 import Axios, { AxiosResponse } from "axios"; 3 import { VotePersonneComplet } from "@/shared/logic/types"; 4 5 export const BASE_URL = adjustUrlOrigin(); 6 7 class Controller extends BaseController { 8 async getVotes() { 9 try { 10 const r: AxiosResponse<VotePersonneComplet[]> = await Axios.post( 11 BASE_URL 12 ); 13 return r.data; 14 } catch (error) { 15 this.notifications.onAxiosError(error); 16 } 17 } 18 19 async doVote(params: VotePersonneComplet) { 20 try { 21 const r: AxiosResponse<VotePersonneComplet[]> = await Axios.put( 22 BASE_URL, 23 params 24 ); 25 return r.data; 26 } catch (error) { 27 this.notifications.onAxiosError(error); 28 } 29 } 30 31 async resetVote(idVote: number) { 32 try { 33 const r: AxiosResponse<VotePersonneComplet[]> = await Axios.delete( 34 BASE_URL, 35 { params: { id: idVote } } 36 ); 37 return r.data; 38 } catch (error) { 39 this.notifications.onAxiosError(error); 40 } 41 } 42 } 43 44 export const C = new Controller();