You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/frontend/src/Store/Actions/Creators/createFetchSchemaHandler.js

36 lines
760 B

import $ from 'jquery';
import { set } from '../baseActions';
function createFetchSchemaHandler(section, url) {
return function(payload) {
return function(dispatch, getState) {
dispatch(set({ section, isFetchingSchema: true }));
const promise = $.ajax({
url
});
promise.done((data) => {
dispatch(set({
section,
isFetchingSchema: false,
schemaPopulated: true,
schemaError: null,
schema: data
}));
});
promise.fail((xhr) => {
dispatch(set({
section,
isFetchingSchema: false,
schemaPopulated: true,
schemaError: xhr
}));
});
};
};
}
export default createFetchSchemaHandler;