How can I access a JSON file in ECMAScript 6?
The following doesn't work:
import config from '../config.json'
This works fine if I try to import a JavaScript file.
In TypeScript or using Babel, you can import json file in your code.
// Babel import * as data from './example.json'; const word = data.name; console.log(word); // output 'testing'
Reference: https://hackernoon.com/import-json-into-typescript-8d465beded79
1.4m articles
1.4m replys
5 comments
56.9k users