2021-01-25 13:10:13 +01:00
|
|
|
import { notificationStore } from "../store/notification"
|
2020-12-30 13:58:39 +01:00
|
|
|
import API from "./api"
|
|
|
|
|
2021-01-04 19:57:16 +01:00
|
|
|
/**
|
|
|
|
* Executes a query against an external data connector.
|
|
|
|
*/
|
2021-01-08 19:22:03 +01:00
|
|
|
export const executeQuery = async ({ queryId, parameters }) => {
|
2021-01-25 12:57:04 +01:00
|
|
|
const res = await API.post({
|
2021-01-08 13:06:37 +01:00
|
|
|
url: `/api/queries/${queryId}`,
|
|
|
|
body: {
|
2021-01-08 19:22:03 +01:00
|
|
|
parameters,
|
2021-01-08 13:06:37 +01:00
|
|
|
},
|
2021-01-04 19:57:16 +01:00
|
|
|
})
|
2021-01-25 12:57:04 +01:00
|
|
|
res.error
|
2021-01-25 13:14:38 +01:00
|
|
|
? notificationStore.danger("En error has occurred")
|
2021-01-25 12:57:04 +01:00
|
|
|
: notificationStore.success("Query successful")
|
2021-01-11 16:34:43 +01:00
|
|
|
return response
|
2021-01-04 19:57:16 +01:00
|
|
|
}
|