Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function time (text, cb) {
return new Promise((res, rej) =>
setTimeout(() => res(text), 100)
);
}
function erroring (text, cb) {
return new Promise((res, rej) =>
setTimeout(() => rej(text), 100)
);
}
export default function fetchResource(url, options = {}) {
return new Promise((resolve, reject) => {
options = assign({}, DEFAULT_OPTIONS, options);
options.headers = assign(
{},
DEFAULT_HEADERS,
normalizeHeaders(options.headers)
);
const data = serializeDataForContentType(
options.data,
options.headers['content-type']
);
const xhr = new XMLHttpRequest();
xhr.open(options.method, url);