0

I have a problem when trying to use a widget.

The script is as follows:

<script type="text/javascript">
baseUrl = "https://widgets.cryptocompare.com/";
var scripts = document.getElementsByTagName("script");
var embedder = scripts[ scripts.length - 1 ];
(function (){
var appName = encodeURIComponent(window.location.hostname);
if(appName==""){appName="local";}
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
var theUrl = baseUrl+'serve/v3/coin/chart?fsym=TPAY*&tsyms=USD';
s.src = theUrl + ( theUrl.indexOf("?") >= 0 ? "&" : "?") + "app=" + appName;
embedder.parentNode.appendChild(s);
})();
</script>

When I access https://widgets.cryptocompare.com/serve/v3/coin/chart?fsym=TPAY*&tsyms=USD from my browser it displays all the data but when using the widget script it does not seem to like the fsym=TPAY&tsym=USD but because cryptocompare lists some currencies that have the same ticker they add a * to the second currency which uses the same ticker name.

Another example of this is PHORE PHR* as they have PHREAK PHR already listed. Funny enough the currencies I would like to use it TPAY* and PHR*.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • What do you mean when you say "it does not seem to like it"? Do you get any specific error? – Joss Classey Dec 13 '18 at 11:25
  • Basically any fsym that includes a currency without a asterisk works so if you were to use BTC in the script it works but ask soon as you use PHR* or TPAY* then it does not work. It seems to break this part - var theUrl = baseUrl+'serve/v3/coin/chart?fsym=TPAY*&tsyms=USD'; – Cosmic Microwave Dec 13 '18 at 11:28
  • I would message their support team about this. – Joss Classey Dec 13 '18 at 11:41
  • I have contacted their support team, the replay was (We are not retrieving any information for Phore (PHR*)/USD this is why the chart is not working since there is no information to display.) but this is incorrect the data is flowing as you can see if you visit https://widgets.cryptocompare.com/serve/v3/coin/chart?fsym=TPAY*&tsyms=USD directly. The problem is the * asterisk used in the query string – Cosmic Microwave Dec 13 '18 at 11:47
  • Maybe try encoding the url string: https://stackoverflow.com/questions/332872/encode-url-in-javascript – Joss Classey Dec 13 '18 at 11:54
  • If the support team are saying "We are not retrieving any information for Phore", that sounds like it will not work until they start receiving that information? – halfer Dec 13 '18 at 19:40
  • (Please use titles to succinctly describe the problem you have. Please do not use them to beg and plead - that is not useful for your readers). – halfer Dec 13 '18 at 19:41

0 Answers0