Wednesday 23 January 2019

Use node to write a variable from js to mongodb

So for a class project I'm creating a browser game in js. At the end of the game I would want to upload the scores to a mongodb database. (and later display it on another page). I've found that you can't write to mongodb with pure js so I'd have to use node.I haven't ever used node.js and tried just adding a function to my existing js file and running it with a json string from another function. However when I do that I get 'require is not defined'.So it seems I can't just add a 'require' function to my other js code and have it ran from inside that js file.To summarize what I'd like to do is take a json string that I have created in my js file upload it to mongodb atlas but out of my depth hereAny help would be awesome

Submitted January 23, 2019 at 01:16PM by CucumberMilkshake

No comments:

Post a Comment