mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-11 13:56:29 +02:00
Initial commit
This commit is contained in:
51
src/services/javGames.ts
Normal file
51
src/services/javGames.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import axios from "axios"
|
||||
|
||||
import config from "../config"
|
||||
|
||||
export interface JavGame {
|
||||
id: number
|
||||
titre: string
|
||||
auteur: string
|
||||
editeur: string
|
||||
minJoueurs: number
|
||||
maxJoueurs: number
|
||||
duree: number
|
||||
type: "Ambiance" | "Famille" | "Expert" | ""
|
||||
poufpaf: string
|
||||
photo: string
|
||||
bggPhoto: string
|
||||
bggId: number
|
||||
exemplaires: number // Defaults to 1
|
||||
dispoPret: number
|
||||
nonRangee: number
|
||||
horodatage: string
|
||||
ean: string
|
||||
}
|
||||
|
||||
export interface JavGameList {
|
||||
data?: JavGame[]
|
||||
error?: Error
|
||||
}
|
||||
|
||||
export interface JavGameData {
|
||||
data?: JavGame
|
||||
error?: Error
|
||||
}
|
||||
|
||||
export const getJavGameList = async (): Promise<JavGameList> => {
|
||||
try {
|
||||
const { data } = await axios.get(`${config.API_URL}/javGames`)
|
||||
return { data }
|
||||
} catch (error) {
|
||||
return { error: error as Error }
|
||||
}
|
||||
}
|
||||
|
||||
export const getJavGameData = async (id: string): Promise<JavGameData> => {
|
||||
try {
|
||||
const { data } = await axios.get(`${config.API_URL}/users/${id}`)
|
||||
return { data }
|
||||
} catch (error) {
|
||||
return { error: error as Error }
|
||||
}
|
||||
}
|
37
src/services/jsonPlaceholder.ts
Normal file
37
src/services/jsonPlaceholder.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import axios from "axios"
|
||||
|
||||
export interface User {
|
||||
id: number
|
||||
name: string
|
||||
phone: string
|
||||
email: string
|
||||
website: string
|
||||
}
|
||||
|
||||
interface UserList {
|
||||
data?: User[]
|
||||
error?: Error
|
||||
}
|
||||
|
||||
interface UserData {
|
||||
data?: User
|
||||
error?: Error
|
||||
}
|
||||
|
||||
export const getUserList = async (): Promise<UserList> => {
|
||||
try {
|
||||
const { data } = await axios.get(`https://jsonplaceholder.typicode.com/users`)
|
||||
return { data }
|
||||
} catch (error) {
|
||||
return { error: error as Error }
|
||||
}
|
||||
}
|
||||
|
||||
export const getUserData = async (id: string): Promise<UserData> => {
|
||||
try {
|
||||
const { data } = await axios.get(`https://jsonplaceholder.typicode.com/users/${id}`)
|
||||
return { data }
|
||||
} catch (error) {
|
||||
return { error: error as Error }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user