Initial commit

This commit is contained in:
forceoranj
2021-10-16 01:53:56 +02:00
commit ebdd8dccdd
104 changed files with 29770 additions and 0 deletions

51
src/services/javGames.ts Normal file
View 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 }
}
}

View 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 }
}
}