Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fetchApi = (url, method, data) => {
url = `/api${url}`
NProgress.start()
NProgress.set(0.4)
const options = {
method,
credentials: 'same-origin',
headers: {
Accept: 'application/json,text/plain,*/*'
}
}
if (rnoContent.test(method)) {
const query = param(data)
if (query) {
url = url + (/\?$/.test(url) ? '' : '?') + query
}
} else if (data) {
options.body = JSON.stringify(data)
options.headers = {
'Content-Type': 'application/json',
export function requestQuestions (args) {
console.log('fetchOptions: ', args);
NProgress.set(0.4);
return function (dispatch) {
return $.ajax({
type: 'POST',
url: '/question/get',
data: JSON.stringify(args),
contentType: 'application/json',
dataType: 'JSON'
}).done((data, textStatus, jqXHR) => {
NProgress.set(0.8);
dispatch(receiveQuestions(data));
});
};
};
limit(async () => {
const data = await translator(item.text, land);
NProgress.set(++index / subtitles.length);
if (data) {
item.text = data;
}
return item;
}),
),
export const handleAsyncFunc = async (asyncFunc, ...args) => {
let result;
try {
NProgress.start();
NProgress.set(0.4);
result = await asyncFunc(...args);
} catch (err) {
result = null;
} finally {
NProgress.done();
return result;
}
};
'global.progress'(val) {
if (val === 0) {
NProgress.set(0)
NProgress.start()
} else if (val === 100) {
NProgress.done()
} else {
NProgress.set(val / 100)
NProgress.start()
}
}
},
export function updateProgress(progress) {
if (0 < progress && progress < 1) {
if (!progressBarStarted) {
progressBarStarted = true;
NProgress.start();
}
NProgress.set(progress);
} else {
progressBarStarted = false;
NProgress.done();
}
return {
type: UPDATE_PROGRESS,
payload: {progress},
};
}
Vue.http.options.progress = function (event) {
if (event.lengthComputable) {
NProgress.set(event.loaded / event.total)
}
}
ws.on('loading', integer => {
if (!isBlobUrl) {
NProgress.set(integer / 100);
}
});
});
function handeLocationChange({ pathname }: any) {
if (pathname == path) {
tryScrollToHash();
return;
}
NProgress.start();
NProgress.set(0.6);
}
const progressObserver = new ScrollProgress((x, y) => {
y >= 0.999 ? NProgress.set(0.999) : NProgress.set(y)
})