23 lines
619 B
TypeScript
23 lines
619 B
TypeScript
/**
|
|
* @deprecated
|
|
*/
|
|
export default function ajaxFetch(opt) {
|
|
let { url, referrer, method, body = null } = opt;
|
|
let req_params: AjaxFetchOpt = {
|
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
|
referrer,
|
|
method,
|
|
};
|
|
if (method === 'POST') {
|
|
req_params.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
|
|
req_params.body = body;
|
|
}
|
|
return window.fetch(url, req_params);
|
|
}
|
|
|
|
interface AjaxFetchOpt {
|
|
headers: { 'X-Requested-With'?: string, 'Content-Type'?: string };
|
|
referrer: string;
|
|
method: string;
|
|
body?: any;
|
|
} |