CLI ionic upload command and JSON assets


#1

Hello. I have some static JSON files located in /assets/data that are loaded by http.get(). This works in-browser when running “ionic serve” as well as within the iOS and Android emulators, but when I use “ionic upload” to see the app in the Ionic View app, my JSON data cannot be accessed. Is there a trick to get this to work, or does the Ionic View app just not support JSON assets? Thanks!


#2

Normally this should make no difference.

Are you doing strange things with paths to access these files? Maybe they are different in Ionic View (which downloads a .zip of your www folder (which you uploaded with ionic upload) and extracts it ).


#3

I don’t think I’m doing anything strange. This is what I’m using: this.http.get(’/assets/data/my-data.json’)…


#4

Fixed! I changed to a relative path, like “./assets/data/my-file.json”. Good to know :slight_smile: