budibase/packages/client/src/api/queries.js

21 lines
513 B
JavaScript
Raw Normal View History

import { notificationStore } from "../store/notification"
2020-12-30 13:58:39 +01:00
import API from "./api"
/**
* Executes a query against an external data connector.
*/
export const executeQuery = async ({ queryId, parameters, notify = false }) => {
2021-01-25 12:57:04 +01:00
const res = await API.post({
url: `/api/queries/${queryId}`,
body: {
2021-01-08 19:22:03 +01:00
parameters,
},
})
if (res.error) {
notificationStore.danger("An error has occurred")
} else if (notify) {
notificationStore.success("Query executed successfully")
}
2021-01-25 13:36:35 +01:00
return res
}