I'm trying to build a news aggregator website, and I'm a beginner. I am getting a error when making a request to https://timesofindia.indiatimes.com/rssfeeds/-2128816011.cms xml rss feed as
error 1: "Access to XMLHttpRequest at 'https://timesofindia.indiatimes.com/rssfeeds/-2128816011.cms' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."
error 2: "GET https://timesofindia.indiatimes.com/rssfeeds/-2128816011.cms net::ERR_FAILED"
I used below code to solve but it didn't work out.
makeCorsRequest();
function createCORSRequest(method, url) {
    var xhr = new XMLHttpRequest();
    if ("withCredentials" in xhr) {
        // XHR for Chrome/Firefox/Opera/Safari.
        xhr.open(method, url, true);
    } else if (typeof XDomainRequest != "undefined") {
        // XDomainRequest for IE.
        xhr = new XDomainRequest();
        xhr.open(method, url);
    } else {
        // CORS not supported.
        xhr = null;
    }
    return xhr;
}
// Helper method to parse the title tag from the response.
function getTitle(text) {
    return text.match('<title>(.*)?</title>')[1];
}
// Make the actual CORS request.
function makeCorsRequest() {
    // This is a sample server that supports CORS.
    var url = 'https://timesofindia.indiatimes.com/rssfeeds/-2128816011.cms';
    var xhr = createCORSRequest('GET', url);
    if (!xhr) {
        alert('CORS not supported');
        return;
    }
    // Response handlers.
    xhr.onload = function() {
        var text = xhr.responseText;
        var title = getTitle(text);
        alert('Response from CORS request to ' + url + ': ' + title);
    };
    xhr.onerror = function() {
        alert('Woops, there was an error making the request.');
    };
    xhr.send();
}
 
     
    