0

I've got a JS file in the utils folder of a nodeJS project. That JS file is responsible for loading data from a database. Right now I only have dummy data that is put in a local JSON file. Now I want to load this local JSON file in my JS file. How do I do this?

I can't use HTTP requests because it's a local JSON file. I can't use use jQuery's $.getJSON() because you can't integrate jQuery into that file.

Is the only thing I can do is inserting the whole JSON object into my JS file?

0

1 Answer 1

1

The require() function can parse and return JSON files.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.