Simple connection to mongodb in react app
You are using node.js so start server app try using express routing here is a link to a tutorial https://zellwk.com/blog/crud-express-mongodb or https://codeburst.io/hitchhikers-guide-to-back-end-development-with-examples-3f97c70e0073 or try doing a google search(node.js mongodb and express).
Then when returning a request from server send the data required then use your react client to handle the data recived
To connect to MongoDb in javascript, you must use a node.js server.It is therefore impossible to directly connect your React application to your MongoDb cluster.
For more information, visit the official MongoDb documentation
Hope it works!
handleSubmit(){let databody = { "name": this.state.name, // Remaining form Data}return fetch('mongodb+srv://mattOsuch:brainhub123@cluster0-jlasm.mongodb.net/test', { method: 'POST', body: JSON.stringify(databody), headers: { 'Content-Type': 'application/json' },}).then(res => res.json()).then(data => console.log(data)); }render(){return ( <div> <form onSubmit={this.handleSubmit}> // Form Fields <input type="submit" value="Save" /> </form> </div>); }