Skip to content

Import JSON file in build folder instead js file #8242

Answered by sapphi-red
ngocducdim asked this question in Q&A
Discussion options

You must be logged in to vote

If you want to load dist/cbs.json, you need to use fetch not import.

const res = await fetch('/cbs.json')
const data = await res.json()

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@syahbes
Comment options

@kissu
Comment options

@sapphi-red
Comment options

@syahbes
Comment options

Answer selected by ngocducdim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
4 participants
Converted from issue

This discussion was converted from issue #8241 on May 20, 2022 12:07.