UNPKG

@woocommerce/data

Version:
28 lines (27 loc) 831 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNotes = void 0; /** * External dependencies */ const url_1 = require("@wordpress/url"); const data_controls_1 = require("@wordpress/data-controls"); /** * Internal dependencies */ const constants_1 = require("../constants"); const actions_1 = require("./actions"); function* getNotes(query = {}) { const url = (0, url_1.addQueryArgs)(`${constants_1.NAMESPACE}/admin/notes`, query); try { const notes = yield (0, data_controls_1.apiFetch)({ path: url, }); yield (0, actions_1.setNotes)(notes); yield (0, actions_1.setNotesQuery)(query, notes.map((note) => note.id)); } catch (error) { yield (0, actions_1.setError)('getNotes', error); } } exports.getNotes = getNotes;