How to post data to mongo collection using Mean stack?

后端 未结 1 1086
南方客
南方客 2021-01-29 04:19

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

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-29 04:59

    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.

    0 讨论(0)
提交回复
热议问题