[frontend] add Accept header to oauthed api requests (#657)

This commit is contained in:
tobi 2022-06-20 10:44:01 +02:00 committed by GitHub
parent 610395d5a5
commit ec81d28a77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,7 +149,7 @@ module.exports = function oauthClient(config, initState) {
return (state.access_token != undefined);
}
function apiRequest(path, method, data, type="json") {
function apiRequest(path, method, data, type="json", accept="json") {
if (!isAuthorized()) {
throw new Error("Not Authenticated");
}
@ -160,7 +160,8 @@ module.exports = function oauthClient(config, initState) {
url.search = s;
}
let headers = {
"Authorization": `Bearer ${state.access_token}`
"Authorization": `Bearer ${state.access_token}`,
"Accept": accept == "json" ? "application/json" : "*/*"
};
let body = data;
if (type == "json" && body != undefined) {