add api token
This commit is contained in:
parent
cdd3167728
commit
7acdd74129
22
main.js
22
main.js
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
const adminSite = "runcity.geo.rictum.ru"
|
const adminSite = "runcity.geo.rictum.ru"
|
||||||
|
|
||||||
|
const adminApiKey = "2|KaYFQk0txpFivlhphdTHDlS37uat8ILuCbVR6HxH9dd21a66"
|
||||||
|
|
||||||
const links = {
|
const links = {
|
||||||
"Волонтеры": "suv_comp",
|
"Волонтеры": "suv_comp",
|
||||||
"Контрольные пункты": "cp_mgmt",
|
"Контрольные пункты": "cp_mgmt",
|
||||||
@ -320,15 +322,23 @@
|
|||||||
return `/${getCompetition()}/cp_mgmt/?action=edit&cp_id=${cpId}`
|
return `/${getCompetition()}/cp_mgmt/?action=edit&cp_id=${cpId}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchApi(route, params) {
|
||||||
|
return await fetch(`https://${adminSite}/api/${route}`, Object.assign({
|
||||||
|
headers: new Headers({
|
||||||
|
'Authorization': `Bearer ${adminApiKey}`,
|
||||||
|
}),
|
||||||
|
}, params))
|
||||||
|
}
|
||||||
|
|
||||||
async function updatePoint(formData) {
|
async function updatePoint(formData) {
|
||||||
return await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/update`, {
|
return await fetchApi(`competitions/${getCompetition()}/update`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deletePoint() {
|
async function deletePoint() {
|
||||||
return await fetch(`https://${adminSite}/api/points/${urlParams().get("cp_id")}`, {
|
return await fetchApi(`points/${urlParams().get("cp_id")}`, {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -338,28 +348,28 @@
|
|||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
params.append(`${field}[]`, value)
|
params.append(`${field}[]`, value)
|
||||||
}
|
}
|
||||||
let response = await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/points?${params.toString()}`, {
|
let response = await fetchApi(`competitions/${getCompetition()}/points?${params.toString()}`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
})
|
})
|
||||||
return await response.json()
|
return await response.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateRoute(formData) {
|
async function updateRoute(formData) {
|
||||||
return await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/route`, {
|
return await fetchApi(`competitions/${getCompetition()}/route`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRoutes() {
|
async function getRoutes() {
|
||||||
let response = await fetch(`https://${adminSite}/api/points/${urlParams().get("cp_id")}/routes`, {
|
let response = await fetchApi(`points/${urlParams().get("cp_id")}/routes`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
})
|
})
|
||||||
return await response.json()
|
return await response.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUnknownPoints() {
|
async function getUnknownPoints() {
|
||||||
let response = await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/routes/${urlParams().get("cat_id")}/unknown`, {
|
let response = await fetchApi(`competitions/${getCompetition()}/routes/${urlParams().get("cat_id")}/unknown`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
})
|
})
|
||||||
return await response.json()
|
return await response.json()
|
||||||
|
Loading…
Reference in New Issue
Block a user