1

Following is the url for yahoo finance api working on browser and also using postman [https://query1.finance.yahoo.com/v8/finance/chart/GOOG?range=1y&includePrePost=false&interval=1mo&corsDomain=finance.yahoo.com&.tsrc=finance][1] but getting an error while running from angular 2 app.

Failed to load https://query1.finance.yahoo.com/v8/finance/chart/GOOG?range=1y&includePrePost=false&interval=1mo&corsDomain=finance.yahoo.com&.tsrc=finance: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

Following is my code

  let url = 'https://query1.finance.yahoo.com/v8/finance/chart/GOOG?range=1y&includePrePost=false&interval=1mo&corsDomain=finance.yahoo.com&.tsrc=finance';
 console.log(url.toString());

       this.http.get(url)

       .subscribe(data => {
      let jsonData = data.json();
      console.log(JSON.stringify(jsonData));
   });

I have also added CORS extension

1 Answers1

0

Thank you Saeed chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security worked for me by opening it into new browser with web security. I hosted the app and after hosting the app I get same error. is there a solution that makes it work on normal browser