mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Headers is a DOM specific class, use Map instead in HomeServerApi
This commit is contained in:
parent
69a8786f8f
commit
277c8af628
@ -55,13 +55,13 @@ export class HomeServerApi {
|
||||
.join("&");
|
||||
url = `${url}?${queryString}`;
|
||||
let bodyString;
|
||||
const headers = new Headers();
|
||||
const headers = new Map();
|
||||
if (this._accessToken) {
|
||||
headers.append("Authorization", `Bearer ${this._accessToken}`);
|
||||
headers.set("Authorization", `Bearer ${this._accessToken}`);
|
||||
}
|
||||
headers.append("Accept", "application/json");
|
||||
headers.set("Accept", "application/json");
|
||||
if (body) {
|
||||
headers.append("Content-Type", "application/json");
|
||||
headers.set("Content-Type", "application/json");
|
||||
bodyString = JSON.stringify(body);
|
||||
}
|
||||
const requestResult = this._requestFn(url, {
|
||||
|
@ -44,6 +44,13 @@ export function fetchRequest(url, options) {
|
||||
referrer: "no-referrer",
|
||||
cache: "no-cache",
|
||||
});
|
||||
if (options.headers) {
|
||||
const headers = new Headers();
|
||||
for(const [name, value] of options.headers.entries()) {
|
||||
headers.append(name, value);
|
||||
}
|
||||
options.headers = headers;
|
||||
}
|
||||
const promise = fetch(url, options).then(async response => {
|
||||
const {status} = response;
|
||||
const body = await response.json();
|
||||
|
Loading…
Reference in New Issue
Block a user