Add getFromApi

pull/3669/merge
iconnor@connortechnology.com 2023-02-22 16:45:40 -05:00
parent 24313b1a59
commit cbabf9d5ce
1 changed files with 8 additions and 1 deletions

View File

@ -44,7 +44,14 @@ var Server = function() {
key: 'urlToApi',
value: function urlToApi() {
const port = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
return this.Protocol + '://' + this.Hostname + (port ? ':' + port : '') + (this.PathToApi && this.PathToApi != 'null' ? this.PathToApi : '');
return (location.protocol=='https:'? 'https:' : this.Protocol+':') + '//' + this.Hostname + (port ? ':' + port : '') + ((this.PathToApi && (this.PathToApi != 'null')) ? this.PathToApi : '');
}
},
{
key: 'getFromApi',
value: function getFromApi() {
const url = this.urlToApi() + (arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '');
return fetch(url + '?' + auth_relay + (arguments.length > 1 && arguments[1] !== undefined ? '&'+arguments[1] : ''));
}
}
]);