To work around the API's CORS restrictions, you'll need to avoid using Javascript directly in the client's browser.
If CORS were allowed, a simple jQuery script like this could fetch data from the API:
$.get('https://api.bitfinex.com/v1/pubticker/btcusd').done(function(resp) {
console.log(resp);
});
Instead, you can create a server-side file (such as in PHP) to handle the HTTP request to the API. By returning the data in the server response and then modifying the code above to query your server-side file, you can work around CORS restrictions by using a proxy hosted on your own domain.
This method, known as a proxy, allows you to bypass CORS limitations effectively.
Alternatively, you can opt for server-side rendering exclusively, querying the endpoint with backend code, and then displaying the results directly without involving the client-side scripting at all.
In your specific example, it's important to note that two code snippets are provided for illustrative purposes - one showing a basic GET request and another utilizing a library. However, only a straightforward GET request to the specified URL is necessary. You can see a preview of the API endpoint by visiting the following link: