Is there a way to add a JSON file to my Ionic project and deploy it with the app to my device and then access it on runtime? I thought about using the assets folder but then again how would I retrieve the content of the assets folder within Typescript?
Deploy JSON file with the app and access it on runtime
Options:
If you import it e.g. import x from './x.json'
it will get built as a part of your bundle. Supported by webpack / ts-loader out of the box.
You can use fetch
to load it at runtime e.g fetch('/assets/x.json').then(x=>x.json()).then(loaded => /*use it */)
.