Skip to content

Tag: node.js

Node.js throws TypeError: Cannot destructure property ‘firstName’ of ‘req.body’ as it is undefined, even though it works for an other post request

So I know there are tons of similar questions out there, and I’ve read most of them in the past few days. However I didn’t find any solution to my problem. The app is about users can post memories(cards) etc… Point is, when I create a new card with POST request, there is no problem, but when…

How to make a function in Node JS run only once

I am creating a simple tictactoe terminal game in JS. I use the variable named player1Input to get user prompt. If the prompt is not equal to “X”, I call the function again to make sure the user input the right input. If I enter the wrong input multiple times, the function (player1Game) ends up be…

Is there a cleaner way to await an https.get?

I stumbled across this post while looking for a way to await reading a file with fs. I was surprised that I hadn’t seen it anywhere else: Is there a way to use await in the same manner shown above, but for the ‘https’ library? I didn’t see anything like .promises and I was hoping to av…