Skip to content

Commit 4bb11e6

Browse files
committed
Fix variable query issue
Fixes #48
1 parent 95e0134 commit 4bb11e6

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.9.2 (2021-02-03)
4+
5+
[Full changelog](https://github.com/marcusolsson/grafana-json-datasource/compare/v0.9.1...v0.9.2)
6+
7+
### Bug fixes
8+
9+
- Variable queries fail with error ([#48](https://github.com/marcusolsson/grafana-json-datasource/issues/48))
10+
311
## 0.9.1 (2021-02-01)
412

513
[Full changelog](https://github.com/marcusolsson/grafana-json-datasource/compare/v0.9.0...v0.9.1)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "marcusolsson-json-datasource",
3-
"version": "0.9.1",
3+
"version": "0.9.2",
44
"description": "A data source plugin for loading JSON APIs into Grafana.",
55
"scripts": {
66
"build": "grafana-toolkit plugin:build",

src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default class Api {
119119
headers: recordHeaders,
120120
};
121121

122-
if (method !== 'GET' && data) {
122+
if (req.method !== 'GET' && data) {
123123
req.data = data;
124124
}
125125

src/datasource.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ export class DataSource extends DataSourceApi<JsonApiQuery, JsonApiDataSourceOpt
116116
const urlPathTreated = templateSrv.replace(query.urlPath);
117117
const jsonPathTreated = templateSrv.replace(query.jsonPath);
118118

119-
const response = await this.api.get(urlPathTreated, queryParamsTreated);
119+
const params: Array<Pair<string, string>> = [];
120+
new URLSearchParams('?' + queryParamsTreated).forEach((value: string, key: string) => {
121+
params.push([key, value]);
122+
});
123+
124+
const response = await this.api.get('GET', urlPathTreated, params);
120125

121126
return JSONPath({
122127
path: jsonPathTreated,

0 commit comments

Comments
 (0)