示例#1
0
文件: dataset.js 项目: Saajan/ui
export function fetchDataSets() {
	/**
	 * CMF actions.http is an action creator that will dispatch an http action.
	 * This action will be caught and executed by the CMF http middleware
	 */
	return actions.http.get('/datasets.json', {
		// action type to dispatch before fetch
		onSend: GETTING_DATASETS,
		// action type to dispatch on fetch error
		onError: ERROR_GETTING_DATASETS,
		// CMF action config
		// collectionId is the key where the result will be stored in app state
		cmf: {
			collectionId: 'datasets',
		},
		// data adaptation before being dispatched
		transform(data) {
			return data.map((row) => {
				const { datastore, ...rest } = row;
				return {
					datastore: datastore.label,
					...rest,
				};
			});
		},
	});
}
示例#2
0
export function buildHttpDelete(uri, labelResource, responseType) {
	return actions.http.delete(uri, {
		onResponse() {
			return {
				type: responseType,
				model: { labelResource },
			};
		},
	});
}