Preload JSON files

I’m trying to preload some JSON files before the app starts, but I keep getting this error:

[Unhandled Promise rejection: TypeError: undefined is not an object (evaluating 'meta.moduleId = moduleId')]

My code is as follows:

await Asset.loadAsync([

Could it be that JSON files are not allowed?

Thanks in advance.

JSON files are automatically parsed into an object – they cannot be used as assets for this reason. If you really want to use as plain text then you could change the extension to .txt. Otherwise if you do const obj = require('blah.json') then obj will already contain the keys of the JSON file like and if blah.json's contents are { foo: ..., bar: ..., ... }.

1 Like

Thanks for clarifying that! I just discovered the File System API, and I’ll try to download my assets and cache them locally.