-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught TypeError: net.createConnection is not a function #1780
Comments
the one way to approach this would be to create a node server that connects to mongodb, and exposes an HTTP API using something like express. then your client-side script could submit the form data to that HTTP API, which in turn would insert the data into mongodb. |
Do you mean something like this? `var express = require('express'); var dbConn = mongodb.MongoClient.connect('mongodb://localhost:27017'); var app = express(); app.post('/post-feedback', function (req, res) { app.listen(process.env.PORT || 3000, process.env.IP || '0.0.0.0' );` |
yeah! something like that should work i think. |
ok thanks, I will try to fix it with this method! |
I'm trying to create a script which inserts data on my MongoDB collection when I submit an HTML form.
So I'm using browserify to use node module 'mongodb', but my bundle.js file (generated with browserify) throws this error on my browser:
I have a script.js that require('mongodb'), so I used this cmd line:
browserify -r mongodb script.js -o bundle.js
Any suggestion?
The text was updated successfully, but these errors were encountered: