Use fetch instead of browser-request

pull/21833/head
David Baker 2019-08-13 16:37:56 +01:00
parent 31fd36efba
commit 2539da0dfa
1 changed files with 12 additions and 17 deletions

View File

@ -68,23 +68,18 @@ async function checkIdentityServerUrl(u) {
// XXX: duplicated logic from js-sdk but it's quite tied up in the validation logic in the // XXX: duplicated logic from js-sdk but it's quite tied up in the validation logic in the
// js-sdk so probably as easy to duplicate it than to separate it out so we can reuse it // js-sdk so probably as easy to duplicate it than to separate it out so we can reuse it
return new Promise((resolve) => { try {
request( const response = await fetch(u + '/_matrix/identity/api/v1');
// also XXX: we don't really know whether to hit /v1 or /v2 for this: we if (response.ok) {
// probably want a /versions endpoint like the C/S API. return null;
// https://github.com/matrix-org/matrix-doc/issues/1665 } else if (response.status < 200 || response.status >= 300) {
{ method: "GET", url: u + '/_matrix/identity/api/v1' }, return _t("Not a valid Identity Server (status code %(code)s)", {code: response.status});
(err, response, body) => { } else {
if (err) { return _t("Could not connect to Identity Server");
resolve(_t("Could not connect to Identity Server")); }
} else if (response.status < 200 || response.status >= 300) { } catch (e) {
resolve(_t("Not a valid Identity Server (status code %(code)s)", {code: response.status})); return _t("Could not connect to Identity Server");
} else { }
resolve(null);
}
},
);
});
} }
export default class SetIdServer extends React.Component { export default class SetIdServer extends React.Component {