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 toolkit13mo 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
mallusrgreatOP13mo 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
Danial13mo ago
Console log process.env.DISCORD_TOKEN and see what it shows
mallusrgreat
mallusrgreatOP13mo 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
Danial13mo ago
Of course
mallusrgreat
mallusrgreatOP13mo ago
nope, this is server-side rendering This is using Next.js dev command. There is a different one for production
darp
darp13mo ago
try rest.setToken('MTA...') before doing requests
mallusrgreat
mallusrgreatOP13mo ago
idk i dont want to do that, in my code
Want results from more Discord servers?
Add your server