UNPKG

@lucsoft/network-connector

Version:

Network Connector the easy way to connect to your HmSYS Network

17 lines (16 loc) 446 B
export class RestFetcher { hmsys; http; constructor(hmsys, http) { this.http = http; this.hmsys = hmsys; } get(id, path) { const auth = this.hmsys().getAuth(); return fetch(`http${this.http ? '' : 's'}://${this.hmsys().url}/api/${id}/${path}`, { headers: new Headers({ 'Authorization': 'Basic ' + btoa(`${auth.id}:${auth.token}`), }) }); } }