2017-04-02 86 views
1

我在看的API涌入文档(https://docs.influxdata.com/influxdb/v1.2/guides/querying_data/),我可以运行这样的卷曲:转换卷曲取回

curl -G 'http://10.111.11.11:9050/query?db=sdp_metrics' --data-urlencode "q=select distinct(host) from jmx where time > now() - 180m" 

我想这个结构转换为取在reactjs,但似乎无法让它工作。在反应,我有这个:

return fetch('http://10.111.11.11:9050/query?db=sdp_metrics&q=' + 'select distinct(host) from jmx where time > now() - 180m' 
      ).then(infltest => { does stuff }) 

浏览器回来了一个200,但我没有得到任何数据回来。

+0

如果我的答案是不正确的,你能澄清,如果这是一个GET或POST请求? (卷曲noob) – FakeRainBrigand

回答

0

尝试:

'http://10.111.11.11:9050/query?db=sdp_metrics&q=' 
    + encodeURIComponent('select distinct(host) from jmx where time > now() - 180m')