tabby-web/src/services/common.service.ts
Eugene Pankov cabbc17581
wip
2021-07-25 14:38:14 +02:00

24 lines
607 B
TypeScript

import { Injectable } from '@angular/core'
@Injectable({ providedIn: 'root' })
export class CommonService {
private configPromise: Promise<any>
backendURL$: Promise<string>
constructor () {
this.configPromise = this.getConfig()
this.backendURL$ = this.configPromise.then(cfg => {
let backendURL = cfg.backendURL
if (backendURL.endsWith('/')) {
backendURL = backendURL.slice(0, -1)
}
return backendURL
})
}
private async getConfig () {
return (await fetch('/config.json')).json()
}
}