Refractor socket store into game store
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import axios from 'axios'
|
||||
import config from '@/config'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useGameStore } from '@/stores/game'
|
||||
import { useCookies } from '@vueuse/integrations/useCookies'
|
||||
|
||||
export async function register(username: string, password: string, socketStore = useSocketStore()) {
|
||||
export async function register(username: string, password: string, gameStore = useGameStore()) {
|
||||
try {
|
||||
const response = await axios.post(`${config.server_endpoint}/register`, { username, password })
|
||||
useCookies().set('token', response.data.token as string)
|
||||
@ -13,7 +13,7 @@ export async function register(username: string, password: string, socketStore =
|
||||
}
|
||||
}
|
||||
|
||||
export async function login(username: string, password: string, socketStore = useSocketStore()) {
|
||||
export async function login(username: string, password: string, gameStore = useGameStore()) {
|
||||
try {
|
||||
const response = await axios.post(`${config.server_endpoint}/login`, { username, password })
|
||||
useCookies().set('token', response.data.token as string, {
|
||||
|
Reference in New Issue
Block a user