From 1ca02672386887d05d49a88f646e0099a94fcfb5 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 18 Dec 2018 14:51:08 -0800 Subject: [PATCH] use application/vnd.flux --- src/datasource.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/datasource.ts b/src/datasource.ts index 9ab83f5..eb13e53 100644 --- a/src/datasource.ts +++ b/src/datasource.ts @@ -131,7 +131,7 @@ export default class InfluxDatasource { if (!query) { return Promise.resolve({data: ''}); } - return this._influxRequest('POST', '/api/v2/query', {query: query}, options); + return this._influxRequest('POST', '/api/v2/query', query, options); } testDatasource() { @@ -145,7 +145,7 @@ export default class InfluxDatasource { }); } - return this._influxRequest('POST', '/api/v2/query', {query: query}) + return this._influxRequest('POST', '/api/v2/query', query) .then(res => { if (res && res.data && res.data.trim()) { return { @@ -164,7 +164,7 @@ export default class InfluxDatasource { }); } - _influxRequest(method: string, url: string, data: any, options?: any) { + _influxRequest(method: string, url: string, query: string, options?: any) { let params: any = {}; if (this.username) { @@ -176,13 +176,14 @@ export default class InfluxDatasource { method: method, url: this.url + url, params: params, - data: data, + data: query, precision: 'ms', inspect: {type: this.type}, }; req.headers = { Accept: 'application/csv', + 'Content-Type': 'application/vnd.flux', }; if (this.basicAuth || this.withCredentials) {