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 toolkit2y 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
mallusrgreatOP2y 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
Danial2y ago
Console log process.env.DISCORD_TOKEN and see what it shows
mallusrgreat
mallusrgreatOP2y 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
Danial2y ago
Of course
mallusrgreat
mallusrgreatOP2y ago
nope, this is server-side rendering This is using Next.js dev command. There is a different one for production
darp
darp2y ago
try rest.setToken('MTA...') before doing requests
mallusrgreat
mallusrgreatOP2y ago
idk i dont want to do that, in my code

Did you find this page helpful?