Initialize @wordpress/api-fetch in automation editor
[MAILPOET-4454]
This commit is contained in:
9
mailpoet/assets/js/src/automation/editor/store/api.ts
Normal file
9
mailpoet/assets/js/src/automation/editor/store/api.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import apiFetch from '@wordpress/api-fetch';
|
||||||
|
import { api } from '../../config';
|
||||||
|
|
||||||
|
const apiUrl = `${api.root}/mailpoet/v1/automation/`;
|
||||||
|
|
||||||
|
export const initializeApi = () => {
|
||||||
|
apiFetch.use(apiFetch.createRootURLMiddleware(apiUrl));
|
||||||
|
apiFetch.use(apiFetch.createNonceMiddleware(api.nonce));
|
||||||
|
};
|
@@ -1,5 +1,6 @@
|
|||||||
import { createReduxStore, register, StoreDescriptor } from '@wordpress/data';
|
import { createReduxStore, register, StoreDescriptor } from '@wordpress/data';
|
||||||
import * as actions from './actions';
|
import * as actions from './actions';
|
||||||
|
import { initializeApi } from './api';
|
||||||
import { storeName } from './constants';
|
import { storeName } from './constants';
|
||||||
import { initialState } from './initial_state';
|
import { initialState } from './initial_state';
|
||||||
import { reducer } from './reducer';
|
import { reducer } from './reducer';
|
||||||
@@ -13,6 +14,8 @@ type StoreType = Omit<StoreDescriptor, 'name'> & {
|
|||||||
name: typeof storeName;
|
name: typeof storeName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
initializeApi();
|
||||||
|
|
||||||
export const store = createReduxStore<State>(storeName, {
|
export const store = createReduxStore<State>(storeName, {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- the "Action" type is missing thunks with "dispatch"
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- the "Action" type is missing thunks with "dispatch"
|
||||||
actions: actions as any,
|
actions: actions as any,
|
||||||
|
Reference in New Issue
Block a user