mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
27 lines
620 B
JavaScript
27 lines
620 B
JavaScript
/**
|
|
* Controls: Implement side effects, typically asynchronous operations.
|
|
*
|
|
* Controls use ACTION_TYPES keys as identifiers.
|
|
* They are triggered by corresponding actions and handle external interactions.
|
|
*
|
|
* @file
|
|
*/
|
|
|
|
import apiFetch from '@wordpress/api-fetch';
|
|
|
|
import { REST_PERSIST_PATH } from './constants';
|
|
import ACTION_TYPES from './action-types';
|
|
|
|
export const controls = {
|
|
async [ ACTION_TYPES.DO_PERSIST_DATA ]( { data } ) {
|
|
try {
|
|
await apiFetch( {
|
|
path: REST_PERSIST_PATH,
|
|
method: 'POST',
|
|
data,
|
|
} );
|
|
} catch ( e ) {
|
|
console.error( 'Error saving progress.', e );
|
|
}
|
|
},
|
|
};
|