Urban

Failing to fetch jsondata from my own URL

Recommended Posts

I am evaluating FC for a financial institution, to be used in an investment portfolio dashboard context.

I use the prepared jsfiddle samples and then try to apply them to my own data in order to evaluate the chart features and behavior.

I have been able to do this as long as the data is copy pasted directly in to the javascript on the jsfiddle page. But when the data series are larger this is not very convenient. For such examples, I notice your jsfiddle versions make use of the fetch(URL_DATA) method, such as in this case of this timeseries example:

https://jsfiddle.net/fusioncharts/1btrzeqa/

Your code looks like this:

const URL_DATA = 'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/master/assets/datasources/fusiontime/examples/online-sales-multi-series/data.json';
const URL_SCHEMA = 'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/master/assets/datasources/fusiontime/examples/online-sales-multi-series/schema.json';

const jsonify = res => res.json();
const dataFetch = fetch(URL_DATA).then(jsonify);
const schemaFetch = fetch(URL_SCHEMA).then(jsonify);

Promise.all([dataFetch, schemaFetch]).then(([data, schema]) => {
  var fusionTable = new FusionCharts.DataStore().createDataTable(data, schema);

I then download your sample data.json file and put it on my own server instead, without tampering with it at all. I change the URL_DATA to reflect the new URL:

const URL_DATA = 'https://starner.se/files/data.json';

But then the fetch no longer works and no chart is rendered.

I would highly appreciate if anyone could point me in the right direction here. Why would the script not accept the data.json file when it is placed on my server? It looks completely like the version found on your URL, when I open the file in my Firefox browser.

Thank you beforehand!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now