mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-22 19:50:12 +00:00
convert sendPost to generic sendData
This commit is contained in:
parent
4838c28557
commit
5b3b882a30
@ -44,16 +44,16 @@ async function sendGet(path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// send post request to API backend
|
// send post/put request to API backend
|
||||||
async function sendPost(path, payload) {
|
async function sendData(path, payload, method) {
|
||||||
|
|
||||||
let access = await getAccess();
|
let access = await getAccess();
|
||||||
const url = `${access.url}:${access.port}/${path}`;
|
const url = `${access.url}:${access.port}/${path}`;
|
||||||
console.log("POST: " + url);
|
console.log(`${method}: ${url}`);
|
||||||
console.log("POST: " + JSON.stringify(payload))
|
console.log(`${method}: ${JSON.stringify(payload)}`);
|
||||||
|
|
||||||
const rawResponse = await fetch(url, {
|
const rawResponse = await fetch(url, {
|
||||||
method: "POST",
|
method: method,
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -109,7 +109,7 @@ async function downloadLink(toDownload) {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
let response = await sendPost(path, payload)
|
let response = await sendData(path, payload, "POST")
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ async function subscribeLink(toSubscribe) {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
let response = await sendPost(path, payload);
|
let response = await sendData(path, payload, "POST");
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user