♻️ Move REST paths to constants.js

This commit is contained in:
Philipp Stracker 2024-11-18 16:32:45 +01:00
parent 84d2af5f39
commit ab8f8e81ae
No known key found for this signature in database
2 changed files with 12 additions and 1 deletions

View file

@ -8,6 +8,16 @@
*/
export const STORE_KEY = 'onboarding';
/**
* REST path to hydrate data of this module by loading data from the WP DB..
*
* Used by: Resolvers
* See: OnboardingRestEndpoint.php
*
* @type {string}
*/
export const REST_HYDRATE_PATH = 'onboarding';
/**
* REST path to persist data of this module to the WP DB.
*

View file

@ -2,13 +2,14 @@ import { dispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { apiFetch } from '@wordpress/data-controls';
import { NAMESPACE } from '../constants';
import { REST_HYDRATE_PATH } from './constants';
import { setIsReady, setOnboardingDetails } from './actions';
/**
* Retrieve settings from the site's REST API.
*/
export function* getPersistentData() {
const path = `${ NAMESPACE }/onboarding`;
const path = `${ NAMESPACE }/${ REST_HYDRATE_PATH }`;
try {
const result = yield apiFetch( { path } );