gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit ec81d28a7767f8dc7863114e9436098af751cd0e
parent 610395d5a55ef0b82b7faaf70127c693d1abd58a
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date:   Mon, 20 Jun 2022 10:44:01 +0200

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


Diffstat:
Mweb/source/lib/oauth.js | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/web/source/lib/oauth.js b/web/source/lib/oauth.js @@ -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) {