Small js fixes
This commit is contained in:
@ -25,7 +25,7 @@ export class Domain {
|
||||
const controller = new AbortController();
|
||||
const timer = setTimeout(() => controller.abort(), 2000);
|
||||
|
||||
let response = await fetch(`https://${domainName}/.well-known/usimp.json`, {
|
||||
const response = await fetch(`https://${domainName}/.well-known/usimp.json`, {
|
||||
redirect: "manual",
|
||||
signal: controller.signal,
|
||||
});
|
||||
@ -166,7 +166,7 @@ export class Session {
|
||||
}
|
||||
|
||||
const startTime = new Date();
|
||||
let response = await fetch(`${this.httpBaseUrl}/${endpoint}`, {
|
||||
const response = await fetch(`${this.httpBaseUrl}/${endpoint}`, {
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
body: JSON.stringify(data),
|
||||
@ -175,7 +175,7 @@ export class Session {
|
||||
const endTime = new Date();
|
||||
clearTimeout(timer);
|
||||
|
||||
let responseData = await response.json();
|
||||
const responseData = await response.json();
|
||||
responseData.duration = endTime - startTime;
|
||||
return responseData;
|
||||
}
|
||||
@ -183,16 +183,19 @@ export class Session {
|
||||
|
||||
async ping() {
|
||||
let result = {"http": null, "ws": null};
|
||||
const res = await this.send("ping", {}, undefined, true);
|
||||
result.http = res.duration;
|
||||
const resHttp = await this.send("ping", {}, undefined, true);
|
||||
result.http = resHttp.duration;
|
||||
|
||||
if (this.wsConnection) {
|
||||
await this.wsConnection.ping();
|
||||
const resWs = await this.send("ping", {});
|
||||
result.ws = resWs.duration;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async authenticate(accountName, password) {
|
||||
let response = await this.send("authenticate", {
|
||||
const response = await this.send("authenticate", {
|
||||
type: "password",
|
||||
name: accountName,
|
||||
password: password,
|
||||
|
Reference in New Issue
Block a user