Q: How to import local json file data to my JavaScript variable? I have data inside employees.json how can I get this data and assign it to the variable inside main.js?

A: You can simply require that file.
const data = require("./data.json");

Here's a working example for you: https://codesandbox.io/s/festive-rgb-75z4o/ in React. Lmk if you have any doubts.

A: Use the below code to import json data in main js file. So your main.js file looks like:
const employees = require('./employees.json');

Now you can use employees variable that contains json data.

A: If you use Babel, you can use this:
import * as data from './employees.json';
const employees = data;

You can use another method using js file.
employees.js
export default
{
  // your json here...
}

And then:
import data from '../employees.js'


A: This might help,Using the Fetch API:
fetch("employees.json")
     .then(response => response.json())
      .then(json => data = (json));

