Akki
Akki

Reputation: 1251

Unable to print complete JSON using console.log

Is there any other way to print data in Sample variable.

Upvotes: 1

Views: 1067

Answers (2)

You have to convert json to string using JSON.stringify before logging.

/* ... */
  loadOnEvent() {   
      console.log(JSON.stringify(Sample));
     //this.state={ locations : Sample };
  }
/* ... */

Upvotes: 2

oklas
oklas

Reputation: 8240

Try to use another way to load. Use fetch if file is remote or use fs if file is local.

If it is memory problem supposed by @Shota consider to use server side processing requests to json file. It is good solution to setup microservice which load json file at startup and handle requests to data struct parsed from json file.


Answer for webpack use case:

Configure webpack to use file-loader or copy-webpack-plugin for specifically this file because it enough big. Consider to load it in parallel with webpack bundle. If your application have big parts which need not each case they must be moved to separated bundles.

Upvotes: 0

Related Questions