async function performWebRequest (url, type = "json", useCorsProxy = false, requestHeaders = undefined, expectedResponseHeaders = undefined, basePath = "/") {
	const request = {};
	let requestUrl;
	if (useCorsProxy) {
		requestUrl = getCorsUrl(url, requestHeaders, expectedResponseHeaders, basePath);
	} else {
		requestUrl = url;
		request.headers = getHeadersToSend(requestHeaders);
	}
	const response = await fetch(requestUrl, request);
	const data = await response.text();

	if (type === "xml") {
		return new DOMParser().parseFromString(data, "text/html");
	} else {
		if (!data || !data.length > 0) return undefined;

		const dataResponse = JSON.parse(data);
		if (!dataResponse.headers) {
			dataResponse.headers = getHeadersFromResponse(expectedResponseHeaders, response);
		}
		return dataResponse;
	}
}
A function to make HTTP requests via the server to avoid CORS-errors.
@param {string} url the url to fetch from
@param {string} type what contenttype to expect in the response, can be "json" or "xml"
@param {boolean} useCorsProxy A flag to indicate
@param {Array.<{name: string, value:string}>} requestHeaders the HTTP headers to send
@param {Array.<string>} expectedResponseHeaders the expected HTTP headers to receive
@param {string} basePath, default /
@returns {Promise} resolved when the fetch is done. The response headers is placed in a headers-property (provided the response does not already contain a headers-property).