move getAccess into function calls

This commit is contained in:
simon 2022-06-20 18:40:17 +07:00
parent fa0fecffcf
commit 4838c28557
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 7 additions and 8 deletions

View File

@ -23,8 +23,9 @@ function getBrowser() {
// send get request to API backend
async function sendGet(path, access) {
async function sendGet(path) {
let access = await getAccess();
const url = `${access.url}:${access.port}/${path}`;
console.log("GET: " + url);
@ -44,8 +45,9 @@ async function sendGet(path, access) {
// send post request to API backend
async function sendPost(path, access, payload) {
async function sendPost(path, payload) {
let access = await getAccess();
const url = `${access.url}:${access.port}/${path}`;
console.log("POST: " + url);
console.log("POST: " + JSON.stringify(payload))
@ -80,8 +82,7 @@ async function getAccess() {
async function verifyConnection() {
const path = "api/ping/";
let access = await getAccess();
let response = await sendGet(path, access)
let response = await sendGet(path)
console.log("verify connection: " + JSON.stringify(response));
return response
@ -108,8 +109,7 @@ async function downloadLink(toDownload) {
}
]
}
let access = await getAccess();
let response = await sendPost(path, access, payload)
let response = await sendPost(path, payload)
return response
@ -126,8 +126,7 @@ async function subscribeLink(toSubscribe) {
}
]
}
let access = await getAccess();
let response = await sendPost(path, access, payload);
let response = await sendPost(path, payload);
return response