Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-import

a test of how we can import JSON in september 2018.

requirements

start

yarn install
yarn start

server will be listening on http://127.0.0.1:8080

tested

fetch('/data.json')
  .then(response => response.json())
  .then(json => console.log(json))
  • Present in all browsers > IE11. See caniuse
  • Can't import JSON file
  • Have to add the type="module" attribute on the script tag
  • No real polyfill
import json from '/data.js'
console.log(json)

using a bundler (parcel in this case)

  • Work in all browsers
  • Can import json
  • Add a build step
import json from '../public/data.json'
console.log(json)

About

a test of how we can import JSON in september 2018

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages