How to get values from JS file to another

So in my Repl in the script.js file I have a large data set (from line 21 to 28) that I decided I wanted to store in the intents.js file. However, I have no idea how I am going to do this. I know in Python, all you have to do is from <file> import <thing> and then use <thing> later in your program, but I don’t know how to mimic that behavior in JS.
I’ve already tried this (you can see at lines 1 and 2) but JS just gave me [object Object] so I stopped using it.

Thanks in advance!

1 Like
import intents from "./intents.js";

is the equivalent of the python import intents.

You probably want to replace line 1 and 2 with

import { intents } from "./intents.js";

as in the javascript equivalent of from <file> import <thing> is import { <thing> } from <file>


I’m gonna try this later, thx!

Note that this is only possible with type=module, which you already have, and that adding only one script tag is necessary for this method.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.