woocommerce/plugins/woocommerce-admin/client/store/notes/resolvers.js

22 lines
446 B
JavaScript
Raw Normal View History

2018-10-11 23:33:18 +00:00
/** @format */
2018-10-12 19:20:48 +00:00
/**
* External dependencies
*/
import { dispatch } from '@wordpress/data';
import apiFetch from '@wordpress/api-fetch';
export default {
async getNotes() {
try {
const notes = await apiFetch( { path: '/wc/v3/admin/notes' } );
dispatch( 'wc-admin' ).setNotes( notes );
} catch ( error ) {
if ( error && error.responseJSON ) {
alert( error.responseJSON.message );
} else {
alert( error );
}
}
},
};