public async loadApi()

in src/components/apis/history-of-api/ko/runtime/api-history.ts [61:96]


    public async loadApi(): Promise<void> {
        const apiName = this.routeHelper.getApiName();

        if (!apiName) {
            this.api(null);
            return;
        }

        if (this.api() && this.api().name === apiName) {
            return;
        }

        try {
            this.apiWorking(true);

            const api = await this.apiService.getApi(`apis/${apiName}`);

            if (api && api.apiVersionSet && api.apiVersionSet.id) {
                const apis = await this.apiService.getApisInVersionSet(api.apiVersionSet.id);
                this.versionApis(apis || []);
            }
            else {
                this.versionApis([]);
            }
            this.selectedId(api.name);
            this.api(api);
            this.apiId = api.id;
        }
        catch (error) {
            throw new Error(`Unable to load API Info. Error: ${error.message}`);
        }
        finally {
            this.apiWorking(false);
        }
        this.getCurrentPage();
    }