Export Dataframe from python / pandas to javascript

I am trying to export data from python to javascript.

I have a python pandas dataframe df that I export to a file “formatted.json” using the following code

with open('../data/formatted.json', 'w') as outfile:

Here’s an excerpt of the ../data/formatted.json file:


I then try to import this data in javascript to read into my react component using

import oddsdata from '../data/formatted.json'

//returns error
Module not found: Can't resolve '../data/formatted.json'

I think the problem is because i dont have an export in my formatted.json file? How can I configure either the python export or the js import to overcome this issue?

the js file is saved in src/betting/betinterface/betinterface.js and the data is saved in src/data/formatted.json


The link to the data file formatted.json is not correct as per our discussion in the comment.

You should change it to

import oddsdata from '../../data/formatted.json'