@lucasschirm/amb-client-react
Version:
Allow to watch records using AMB Websockets from a react application.
22 lines (21 loc) • 632 B
JavaScript
import WindowNotDefined from "./errors/WindowNotDefined";
export var getServerUrl = function (instance) {
if (instance) {
var url = instance;
// if instance ends with /, remove it
if (url.endsWith("/")) {
url = url.slice(0, -1);
}
return "wss://".concat(url);
}
// if window is not defined throw error
if (!window) {
throw new WindowNotDefined();
}
// get current domain
var host = window.location.host;
return "wss://".concat(host);
};
export var getAmbPath = function (instance) {
return "".concat(getServerUrl(instance), "/amb");
};