refactor receiving of json
This commit is contained in:
parent
aa98770385
commit
1b56a8ba12
16
main.js
16
main.js
@ -307,9 +307,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getPointIdByNumber(number) {
|
async function getPointIdByNumber(number) {
|
||||||
return await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/${number}`, {
|
let response = await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/${number}`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
})
|
})
|
||||||
|
return await response.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateRoute(formData) {
|
async function updateRoute(formData) {
|
||||||
@ -320,15 +321,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getRoutes() {
|
async function getRoutes() {
|
||||||
return await fetch(`https://${adminSite}/api/points/${urlParams().get("cp_id")}/routes`, {
|
let response = await fetch(`https://${adminSite}/api/points/${urlParams().get("cp_id")}/routes`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
})
|
})
|
||||||
|
return await response.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUnknownPoints() {
|
async function getUnknownPoints() {
|
||||||
return await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/routes/${urlParams().get("cat_id")}/unknown`, {
|
let response = await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/routes/${urlParams().get("cat_id")}/unknown`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
})
|
})
|
||||||
|
return await response.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
function relatedPointsHref() {
|
function relatedPointsHref() {
|
||||||
@ -1159,8 +1162,7 @@
|
|||||||
on: {
|
on: {
|
||||||
click: async function () {
|
click: async function () {
|
||||||
let number = document.querySelector("#go-to-cp").value
|
let number = document.querySelector("#go-to-cp").value
|
||||||
let response = await getPointIdByNumber(number)
|
let json = await getPointIdByNumber(number)
|
||||||
let json = await response.json()
|
|
||||||
let id = json.id
|
let id = json.id
|
||||||
|
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
@ -1637,7 +1639,7 @@
|
|||||||
|
|
||||||
function addRoutesList() {
|
function addRoutesList() {
|
||||||
(async () => {
|
(async () => {
|
||||||
let routes = await (await getRoutes()).json()
|
let routes = await getRoutes()
|
||||||
|
|
||||||
if (routes.length == 0) return
|
if (routes.length == 0) return
|
||||||
|
|
||||||
@ -2191,7 +2193,7 @@
|
|||||||
|
|
||||||
function showUnknownPoints() {
|
function showUnknownPoints() {
|
||||||
(async () => {
|
(async () => {
|
||||||
let unknownPoints = await(await getUnknownPoints()).json()
|
let unknownPoints = await getUnknownPoints()
|
||||||
if (unknownPoints.length) {
|
if (unknownPoints.length) {
|
||||||
let unknownPointsContainer = Tag.div()
|
let unknownPointsContainer = Tag.div()
|
||||||
unknownPointsContainer.append("Несохраненные точки: ")
|
unknownPointsContainer.append("Несохраненные точки: ")
|
||||||
|
Loading…
Reference in New Issue
Block a user