fix(achievements): inject Authorization header in plugin API calls
This commit is contained in:
@@ -50,7 +50,9 @@
|
|||||||
|
|
||||||
async function api(path, options) {
|
async function api(path, options) {
|
||||||
const url = "/api/plugins/hermes-achievements" + path;
|
const url = "/api/plugins/hermes-achievements" + path;
|
||||||
const res = await fetch(url, options || {});
|
const token = window.__HERMES_SESSION_TOKEN__ || "";
|
||||||
|
const headers = { ...(options?.headers || {}), Authorization: `Bearer ${token}` };
|
||||||
|
const res = await fetch(url, { ...options, headers });
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const text = await res.text().catch(function () { return res.statusText; });
|
const text = await res.text().catch(function () { return res.statusText; });
|
||||||
throw new Error(res.status + ": " + text);
|
throw new Error(res.status + ": " + text);
|
||||||
|
|||||||
Reference in New Issue
Block a user