0

Im trying to send data to a local mongo database that i've got, but im not entirely sure why its not sending anything. I'd like to send the form data to the database. The idea is that its meant to send the form data over to the mongo database to be stored under the fields from the register.

3
  • 1
    You need to narrow down where it fails. Start with examining the POST request in the browser's dev tools. Commented Mar 11, 2019 at 21:29
  • Your Express controller for the route '/newtask' doesn't seem to have a logic for saving(inserting) data. It only has findOne(). You should include insert() in order to save the data from the client. Commented Mar 11, 2019 at 23:20
  • @ChrisG I tried checking after i signed the form and pressed the button but nothing new appears in the network section Commented Mar 12, 2019 at 21:19

1 Answer 1

1

If you are doing read or write operation in control.js, your mongo connection mongoose.connection() should be in control.js and it seems you are not using the url to connect to mongodb. And what is the output in control.js console.log(htask);

And if you would like to find one doc, if found return the doc if not found add one doc, you can use {upsert:true,returnNewDocument:true} in options.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.