Error: Expected token to be set for this request, but none was present

useEffect(() => {
discordRest.get(Routes.user(voter.userId)).then((data) => {
console.log(data);
setUser(data);
});
}, [voter.userId]);
useEffect(() => {
discordRest.get(Routes.user(voter.userId)).then((data) => {
console.log(data);
setUser(data);
});
}, [voter.userId]);
No description
8 Replies
d.js toolkit
d.js toolkit6mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
mallusrgreat
mallusrgreat6mo ago
import { REST } from "@discordjs/rest";
const discordRest = new REST({ version: "10" }).setToken(
process.env.DISCORD_TOKEN
);
export default discordRest;
import { REST } from "@discordjs/rest";
const discordRest = new REST({ version: "10" }).setToken(
process.env.DISCORD_TOKEN
);
export default discordRest;
Danial
Danial6mo ago
Console log process.env.DISCORD_TOKEN and see what it shows
mallusrgreat
mallusrgreat6mo ago
Hmm. Doesn't work in the exact functional component I'm writing this in, but works in the main component I'm gonna look into this, ty
Danial
Danial6mo ago
Of course
mallusrgreat
mallusrgreat6mo ago
nope, this is server-side rendering This is using Next.js dev command. There is a different one for production
darp
darp6mo ago
try rest.setToken('MTA...') before doing requests
mallusrgreat
mallusrgreat6mo ago
idk i dont want to do that, in my code