forked from CSGOWTF/csgowtf
added api util functions
This commit is contained in:
@@ -15,14 +15,14 @@ export const GetUser = async (id) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const TrackMe = async (id64, authcode, sharecode) => {
|
||||
export const TrackMe = async (id64, authcode, sharecode = '') => {
|
||||
let statusError = ''
|
||||
let status = 202
|
||||
|
||||
const shareCodeRegex = /^CSGO(?:-?[ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789]{5}){5}$/
|
||||
const authCodeRegex = /^[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{5}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}$/
|
||||
|
||||
if (sharecode && !shareCodeRegex.test(sharecode)) {
|
||||
if (sharecode !== '' && !shareCodeRegex.test(sharecode)) {
|
||||
statusError = 'Is not a valid sharecode'
|
||||
status = 418
|
||||
return [status, statusError]
|
||||
@@ -67,9 +67,35 @@ export const getPlayerValue = async (match_id) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const loadMoreMatches = async (player_id, date) => {
|
||||
export const getMatchDetails = async (match_id) => {
|
||||
try {
|
||||
const res = await axios.get(`${API_URL}/player/${player_id}/after/${date}`)
|
||||
const res = await axios.get(`${API_URL}/match/${match_id}`)
|
||||
|
||||
if (res.status === 200) {
|
||||
return res.data
|
||||
}
|
||||
} catch (err) {
|
||||
// TODO: 400, 404
|
||||
console.log(err.response.status, err.response.statusText)
|
||||
}
|
||||
}
|
||||
|
||||
export const loadMoreMatches = async (player_id, date) => {
|
||||
try {
|
||||
const res = await axios.get(`${API_URL}/player/${player_id}/next/${date}`)
|
||||
|
||||
if (res.status === 200) {
|
||||
return res.data
|
||||
}
|
||||
} catch (err) {
|
||||
// TODO: 400, 404
|
||||
console.log(err.response.status, err.response.statusText)
|
||||
}
|
||||
}
|
||||
|
||||
export const getPlayerMeta = async (player_id, limit = 4) => {
|
||||
try {
|
||||
const res = await axios.get(`${API_URL}/player/${player_id}/meta/${limit}`)
|
||||
|
||||
if (res.status === 200) {
|
||||
return res.data
|
||||
|
||||
Reference in New Issue
Block a user