this is the error this is the code this line gives error let token = msg.content.split(‘ ‘); i have blanked it out this fetches giphy gif // Here we get the data array from the response object // We pass the array to showGiphs function // We use catch method for Error handling Answer You’re …
Tag: node.js
Redirecting to previous page in Passport.js after authentication (not duplicate) Node.js
I am trying to redirect back to the page when I am redirected to log in. I am using Passport and connect-ensure-login, and the login works, however, it gets annoying having to re-click the link (if you are not logged in, it redirects you to the home page, but the link has a query string). Is there a way to
Language getting detected but translation not working with i18n
I have set up the i18n middleware in my Express Node js server like this: Here is the translation test file: The value of title in English is title and for Malaysian, it’s tajuk As per the express middleware documentation, I’m passing my as the accept-language header , and console.log(req.i18n.lan…
Promise not fulfilled
This is a basic question. I’m working through a js/node workshop on async programming called promise-it-wont-hurt. I have the following exercise: my test.js file contains: When I run “node test.js” at the command line , I get no output. What am I doing wrong? Answer All this does is return t…
Why I can’t use ‘require’ built in module in node?
I’m trying to initialise a very simple server using node. As I understand ‘require’ and ‘HTTP’ are built-in modules which I can use. So my code looks as the following: const http = require(‘http’); …
My Discord bot is sending multiple messages at once using discord.js
For some reason the bot is posting in the discord more than once. I am unsure how to fix this at this moment. I’ve exhausted all options and even restarted the code and the bot itself and I am not to sure where to go on from here. You can find my code below: youtube.js Answer I would suggest that
loading javascript classes stored in database
I have a react application, using webpack. In my application, I allow users to overwrite default behaviors with their own custom behavior. For example lets say the application has a button that when clicked would alert a message to the user and this user would rather not be annoyed with an alert box they woul…
Multiple if/else conditions (discord bot)
I’m trying to create a simple discord bot, currently using nodeJS. I’m creating specific commands that only specific users can use and whenever someone who does not have permission to use such command can get a reply “You don’t have permission”. (I hope you get the idea. sorry fo…
Stop game loop on conditional with React
I am unable to stop the loop after a conditional. I am able to stop the interval after a button click but unable to stop it after a conditional such as loop increments. This simple example tries to stop the interval loop after 5 loops. Any solutions would be much appreciated! Answer The solution is to put the…
is it possible to make an on(consolelog event? it would do something every time text is logged to console
This feature would do something every time text is logged to the node.js console. Here’s a somewhat of example of how I think it should look like: on(‘console’, msg => {console.log(“text was logged! ” + msg)}) Regular node.js Answer Console methods don’t emit events, but…