Skip to content

Commit

Permalink
fix: Object(...) is not a function error
Browse files Browse the repository at this point in the history
  • Loading branch information
hbollon committed Jun 7, 2022
1 parent 591cc08 commit da97b6f
Show file tree
Hide file tree
Showing 2 changed files with 669 additions and 467 deletions.
5 changes: 2 additions & 3 deletions src/DataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from '@grafana/data';
import { getBackendSrv, getTemplateSrv } from '@grafana/runtime';
import { GenericOptions, CustomQuery, QueryRequest, defaultQuery } from './types';
import { firstValueFrom } from 'rxjs';

export class AlertmanagerDataSource extends DataSourceApi<CustomQuery, GenericOptions> {
url: string;
Expand Down Expand Up @@ -53,7 +52,7 @@ export class AlertmanagerDataSource extends DataSourceApi<CustomQuery, GenericOp
const request = this.doRequest({
url: `${this.url}/api/v2/alerts?${params.join('&')}`,
method: 'GET',
}).then((request) => firstValueFrom(request));
}).then((request) => request.toPromise());

return request.then((data: any) => this.retrieveData(query, data));
});
Expand All @@ -68,7 +67,7 @@ export class AlertmanagerDataSource extends DataSourceApi<CustomQuery, GenericOp
url: this.url,
method: 'GET',
}).then((response) =>
firstValueFrom(response).then((data) => {
response.toPromise().then((data) => {
if (data !== undefined) {
if (data.ok) {
return { status: 'success', message: 'Datasource is working', title: 'Success' };
Expand Down
Loading

0 comments on commit da97b6f

Please sign in to comment.