2018-07-05 03:14:40 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { dispatch } from '@wordpress/data';
|
2018-08-21 19:02:49 +00:00
|
|
|
import apiFetch from '@wordpress/api-fetch';
|
2018-07-05 03:14:40 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
async getOrders() {
|
|
|
|
try {
|
2018-08-21 19:02:49 +00:00
|
|
|
const orders = await apiFetch( { path: '/wc/v3/orders' } );
|
2018-07-05 03:14:40 +00:00
|
|
|
dispatch( 'wc-admin' ).setOrders( orders );
|
|
|
|
} catch ( error ) {
|
|
|
|
if ( error && error.responseJSON ) {
|
|
|
|
alert( error.responseJSON.message );
|
|
|
|
} else {
|
|
|
|
alert( error );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|