PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.14
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.14
1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 1.3.47 1.3.46 1.3.45 All 177 releases
disco / backend / views / components / Analytics / features / api / analyticsApi.js

analyticsApi.js in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.4.14, at backend/views/components/Analytics/features/api/analyticsApi.js

32 lines 896 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* eslint-disable no-undef */
2 import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
3
4 const rawBaseQuery = fetchBaseQuery({
5 baseUrl: DISCO.json_url + '/analytics',
6 prepareHeaders: (headers) => {
7 headers.set('X-WP-Nonce', DISCO.rest_nonce);
8 },
9 });
10
11 const baseQuery = (args, api, extraOptions) => {
12 if (args && typeof args === 'object' && args.params) {
13 const { params, url, ...rest } = args;
14 const stripped = Object.fromEntries(
15 Object.entries(params).filter(([, v]) => v !== undefined)
16 );
17 const queryString = new URLSearchParams(stripped).toString();
18 const separator = DISCO.is_pretty_url ? '?' : '&';
19 args = {
20 ...rest,
21 url: queryString ? `${url}${separator}${queryString}` : url,
22 };
23 }
24 return rawBaseQuery(args, api, extraOptions);
25 };
26
27 export const analyticsApi = createApi({
28 reducerPath: 'analyticsApi',
29 baseQuery,
30 endpoints: () => ({}),
31 });
32