Access data source from an app type plugin page

Oh sorry. Looks like the repo is private for some reason. Not sure why it should be public. Here is another link:

And here is the code from the first link:

loadDatasource(id) {
    return this.backendSrv.get('api/datasources/' + id)
      .then(ds => {
        this.datasource = ds.jsonData.ds;
        return this.datasourceSrv.get(ds.name);
      }).then(clusterDS => {
        this.clusterDS = clusterDS;
        return clusterDS;
      });
  }

and an example of using the data source (the data source has function called getPod):

this.loadDatasource(this.cluster_id).then(() => {
        this.clusterDS.getPod(pod_name).then(pod => {
          this.pod = pod;
          this.pageReady = true;
        });
      });
2 Likes