While working on a project, I encountered an issue with the API call not returning any conversion data. The Browser Network tab showed a status code of 200, but the method was OPTIONS instead of GET. Even though CORS is allowed for any origin, method, and header, it seems like the OPTIONS call might be preventing the GET call from going through. How can I troubleshoot this situation?
I am developing in Angular 5 and here is my code snippet:
getCurrencyWisePriceFromBDT(price: number, toCurrency: string): any {
let currencyConversionUrl = "https://free.currencyconverterapi.com/api/v6/convert?q=BDT_";
currencyConversionUrl = currencyConversionUrl + toCurrency;
console.log(currencyConversionUrl);
let rateInNewCurrency;
this.http.get < any > (currencyConversionUrl).subscribe(data => {
console.log(data);
rateInNewCurrency = data.val;
console.log(rateInNewCurrency);
return rateInNewCurrency * price;
});
}
Unfortunately, Chrome is giving me this error message:
Failed to load https://free.currencyconverterapi.com/api/v6/convert?q=BDT_USD: Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.