0

I'm trying to fetch data from a JSON file. I want this file to be in the application, so no fetch on a server, local storage only.

How do I do that?

I search on the internet, and it's either fetch on a server, or add data to AsyncStorage (or similar).

If I were in python, I would simply do this :

import json

data = json.load(open('data.json'))

Then I could use the data as I see fit.

Thanks in advance.

Note : I have the file in JSON, but I could change it to any format that is supported by python (my script for parsing and generating the data is in python).

1
  • 1
    Simply import your json file like const data = require("./data.json") or import data from "./data.json" Commented Mar 3, 2018 at 2:11

1 Answer 1

1

Simply import your json file like const data = require("./data.json") or import data from "./data.json" – @Tuấn Trần Duy

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.