i am trying to validate the string using the JOI package available in npm, i checked this documentation which has many useful string formats e.g. date, IP, base64 but i need to validate the following JSON which contains a stringified JSON as a value, and there is no example in the documentation for such case …
Tag: node.js
How to deal with a TokenExpiredError: jwt expired?
I have a project with NodeJS with jwt for managing user authentication. After a period of time, my app stops working and my server prints the following: Now, the person who was working in this project before me had this code for managing the tokens: My guess is that the issue is the expiresIn: ‘7d’…
How to retry an async function with a delay in javascript?
I am trying to fetch a record from a database. Due to race conditions it is possible and even likely that the record isn’t there when I first try to fetch it. How do I wrap this in a retry logic without going mad? I seem to be too stupid for it This code should retry n times with a
401 Unauthorized error when uploading an image to Cloudinary in specific folder on signed upload preset
I have a social media app, and when a user wants to upload a profile picture, they must obtain a signature from the server. This code works when I remove the upload preset in the front end, but I want the upload preset so that the user can upload to a specific folder, and it is a signed upload preset,
Refactoring Embed message generation for Discord Bot
I am trying to refactor the code that I am using to generate embeds (user input makes an API call for info, which I display through the embed) with my bot in Discord. I have both a slash command and prefix command version of the code (so that people can either ask the bot with a prefix command or use
SyntaxError: Unexpected token ” in JSON at position 0 at JSON.parse
I am not able to clearly Identify the bug, data is send in JSON Format still it is showing unusual error Forgot Password Route forgotPassword Action.js As mentioned in some answers online available I have made few changes but Error is still their, In Action.js I have written content type as “application…
Redirect requests inside html page to go through proxy
I have a proxy, and I’ve fetched contents of the webpage I need, like https://google.com. However, I need to be able to then also redirect all the other requests for resources to go through the proxy. So, all images and scripts go back through the proxy. Additionally, all links also go back through the …
Cast to string failed for value Error when submitting the form, using FileBase from React to convert the image
I have an error when i try to post this schema data into Form.js. Mongoose schema looks like this: Logic for creating post is like this: I’m uploading image as String and I’m converting image using base64 from React like this- When I try to submit form, I get error like – {“messageR…
Discord.js v13 code breaks when upgrading to v14
I’ve just updated my discord.js from v13 to v14 and there are many errors. Errors with intents: Errors with interactions: Errors with channels: Errors with builders and embeds: Errors with enums: Answer Discord.js v14 includes many breaking changes. It now requires Node 16.9 or higher to use, so make su…
Printing a HTML + JavaScript variable from an external js to an index.html file using fetch + node.js
I was under the impression I could use node.js to do this but you cannot b/c of reasons given by the answer. Essentially I just wanted to use fetch and that’s all you really need. Here is a very basic way of using it. Here was the non-working node.js code: index.js Inside fetchWeatherJSON().then(……