Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return dispatch => {
return isomorphicFetch(completeUrl, {})
.then(response => response.json())
.then(function(data) {
if (data.state == 'SUCCESS') {
taskManager.removeTask(taskId);
dispatch(dispatcher(dispatcherParams, data.result));
} else if (data.state == 'FAILURE') {
taskManager.removeTask(taskId);
console.error(data.error);
Raven.captureException(new Error(data.error));
dispatch(errorDispatcher(data));
} else if (counter > limit) {
revokeTasks(taskId).then((revokeData) => {
dispatch(dispatcher(dispatcherParams, { ...data.result, error: 'Took too long to get visualizations.' }));
});
} else {
if (progressDispatcher && data.currentTask) {
export function rawFetch(urlPath, options) {
const completeUrl = API_URL + urlPath;
return isomorphicFetch(completeUrl, { ...options, credentials: 'include' });
}
export function rawFetch(...args) {
return isomorphicFetch['default'](...args);
}
function revokeTasks(taskIds) {
const completeUrl = API_URL + '/tasks/v1/revoke';
var options = {
headers: { 'Content-Type': 'application/json' },
method: 'post',
body: JSON.stringify({ 'task_ids': taskIds })
};
taskManager.removeTasks(taskIds);
return isomorphicFetch(completeUrl, options).then(response => response.json());
}