1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

Add safety for when the endpoint doesn't exist

This commit is contained in:
Travis Ralston
2019-01-28 17:18:57 -07:00
parent 971d572fbf
commit 2d4e9d0d3f

View File

@@ -408,9 +408,11 @@ MatrixClient.prototype.getCapabilities = function() {
return Promise.resolve(this._cachedCapabilities.capabilities); return Promise.resolve(this._cachedCapabilities.capabilities);
} }
} }
// We swallow errors because we need a default object anyhow
return this._http.authedRequest( return this._http.authedRequest(
undefined, "GET", "/capabilities", undefined, "GET", "/capabilities",
).then((r) => { ).catch(() => null).then((r) => {
if (!r) r = {}; if (!r) r = {};
const capabilities = r["capabilities"] || {}; const capabilities = r["capabilities"] || {};
this._cachedCapabilities = { this._cachedCapabilities = {