24 lines
927 B
JavaScript
24 lines
927 B
JavaScript
import { fetchRespHandler } from "../utils/http"
|
|
|
|
const API_ENDPOINT = "https://grafana.fiskerdps.com/api/datasources/proxy/2"
|
|
|
|
const grafanaAPI = {
|
|
getCarsCount: async () => fetch(`${API_ENDPOINT}/?query=SELECT%20countDistinct(vin)%20as%20count%0AFROM%20default.vehicle_data%20FORMAT%20JSON`, {
|
|
method: "GET",
|
|
headers: Object.assign({ "Content-Type": "application/json" }),
|
|
})
|
|
.then(fetchRespHandler)
|
|
.then(result => result.data[0].count)
|
|
.catch(error => console.log(error)),
|
|
|
|
getSignalsCount: async () => fetch(`${API_ENDPOINT}/?query=SELECT%20count()%20as%20count%0AFROM%20default.vehicle_signal%20FORMAT%20JSON`, {
|
|
method: "GET",
|
|
headers: Object.assign({ "Content-Type": "application/json" }),
|
|
})
|
|
.then(fetchRespHandler)
|
|
.then(result => result.data[0].count)
|
|
.catch(error => console.log(error)),
|
|
};
|
|
|
|
export default grafanaAPI;
|