Skip to content Skip to sidebar Skip to footer

How To Post Data To Mongo Collection Using Mean Stack?

I have a object that contains firstname and lastname from client it is printing in client factory so i am new to backend development so i created user schema and api to post the da

Solution 1:

Angular error stack trace is very clear.
You do not handle this specific endpoint for your POST query in your express router.

So the server throw a 404 error, as it should.

Try something like this:

router
    .post('/api/users', function (req, res) {
       // do what you want with your user here
    })

With express (and NodeJS) you must explicitly specify each access to server resources.

As side note, you are pretty close to this but try to keep your application logic simple for maintenability.


Post a Comment for "How To Post Data To Mongo Collection Using Mean Stack?"