How to post data to mongo collection using Mean stack?

别等时光非礼了梦想. 提交于 2019-12-02 10:21:50

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!