Merge branch 'main' into merge_branch
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import axios from "axios"
|
||||
|
||||
export const API_CONFIG = {
|
||||
baseURL: import.meta.env.VITE_API_URL+'/api',
|
||||
wsURL: 'http://localhost:3000',
|
||||
baseURL: import.meta.env.VITE_API_URL + "/api",
|
||||
wsURL: "http://localhost:3000",
|
||||
timeout: 10000,
|
||||
retryAttempts: 3
|
||||
};
|
||||
retryAttempts: 3,
|
||||
}
|
||||
|
||||
export const apiClient = axios.create({
|
||||
baseURL: API_CONFIG.baseURL,
|
||||
@@ -19,20 +18,40 @@ export const apiClient = axios.create({
|
||||
|
||||
//login
|
||||
export const login = async (username, password) => {
|
||||
try {
|
||||
const response = await apiClient.post('/users/login', { username, password });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
try {
|
||||
const response = await apiClient.post("/users/login", { username, password })
|
||||
return response.data
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
//register
|
||||
export const register = async (username, email, password, fname, lname, phone) => {
|
||||
try {
|
||||
const response = await apiClient.post('/users/create', { username, email, password, fname, lname, phone });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
try {
|
||||
const response = await apiClient.post("/users/create", { username, email, password, fname, lname, phone })
|
||||
return { ...response.data, status: response.status }
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
//verify email
|
||||
export const verifyEmail = async (token) => {
|
||||
try {
|
||||
const response = await apiClient.get(`/users/verify-email/${token}`)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Get current user's game statistics
|
||||
export const getUserStats = async () => {
|
||||
try {
|
||||
const response = await apiClient.get("/users/me/stats")
|
||||
return response.data
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user