%PDF- %PDF-
Direktori : /home/emergentqj/actioncivile/pre-auth/.632e77b3fb93bc8da5b589b869bc0037/static/js/common/actions/ |
Current File : /home/emergentqj/actioncivile/pre-auth/.632e77b3fb93bc8da5b589b869bc0037/static/js/common/actions/index.js |
import axios from "axios"; // import * as Sentry from "@sentry/browser"; const transactionId = Math.random() .toString(36) .substr(2, 9); // Sentry.configureScope((scope) => { // scope.setTag("transaction_id", transactionId); // }); function dataAction( method, url, params = null, auth = false, headers = {}, responseType = null, options = null, ) { return () => { const requestHeaders = headers; const config = { url, method, timeout: 20000, params: method === "get" || method === "delete" ? params : null, data: method === "put" || method === "post" || method === "path" || method === "delete" ? params : null, headers: { ...requestHeaders, }, validateStatus: (status) => status < 300, ...options, }; if (!config.url.includes("faq")) { config.headers = { "X-Transaction-ID": transactionId, ...config.headers }; } if (responseType) { config.responseType = responseType; } if (auth) { config.withCredentials = true; } return axios .request(config) .then((response) => response) .catch((error) => { throw error; }); }; } export function getDataAction( url, params = null, auth = false, headers = {}, responseType = null, ) { return dataAction("get", url, params, auth, headers, responseType); } export function postDataAction(url, params = null, auth = false, headers = {}) { return dataAction("post", url, params, auth, headers); } // All occurences of postDataAction should be replaced by this one export function postDataAction2({ url, params, auth, headers, options, }) { return dataAction("post", url, params, auth, headers, null, options); } export function putDataAction(url, params = null, auth = false, headers = {}) { return dataAction("put", url, params, auth, headers); } export function deleteDataAction( url, params = null, auth = false, headers = {}, ) { return dataAction("delete", url, params, auth, headers); }