@woocommerce/data
Version:
WooCommerce Admin data store and utilities
31 lines (30 loc) • 955 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getShippingMethods = void 0;
/**
* External dependencies
*/
const data_controls_1 = require("@wordpress/data-controls");
/**
* Internal dependencies
*/
const actions_1 = require("./actions");
const constants_1 = require("../constants");
function* getShippingMethods(forceDefaultSuggestions = false) {
let path = constants_1.WC_ADMIN_NAMESPACE + '/shipping-partner-suggestions';
if (forceDefaultSuggestions) {
path += '?force_default_suggestions=true';
}
yield (0, actions_1.getShippingMethodsRequest)();
try {
const results = yield (0, data_controls_1.apiFetch)({
path,
method: 'GET',
});
yield (0, actions_1.getShippingMethodsSuccess)(results);
}
catch (error) {
yield (0, actions_1.getShippingMethodsError)(error);
}
}
exports.getShippingMethods = getShippingMethods;