I building a discord bot and I want to decleare a function in another file to keep my documents cleaner.
I have 2 files:
function.js
const needle = require("needle");
async function get() {
const res = await needle("get", endpointURL, params, {
headers: {
"User-Agent": "v2LikingUsersJS",
authorization: `Bearer ${token}`
},
});
if (res.body) {
return res.body;
} else {
throw new Error("Unsuccessful request");
};
};
index.js
const imp = require("./function");
const data = await get();
If I run this code I get the error 'get is not a function'
I also tried:
"const data = await imp.get()";
Can anyone help me to get this running ? Thank for your help in advance.