Ionic post-request to nodejs

I am doing a post request to my nodeJS server like this.

So whenever i click on the button it gives a post with a JSON: if i console.log the JSON it gives me the good parameters so that’s not the problem.

 let data = {
        username: this.username,
        email: this.email,
        password1: this.password1,
        password2: this.password2
    };

    this.http.post("http://localhost:3000/", data, {}).subscribe(data => {
          this.dataUser = data;
        }, error => {
            console.log(error);
        });

and from my server.js i do this to get the post but i get a

POST http://localhost:3000/ 404 (Not Found)

so i have no clue how to fix this. On my server side so the server.js file i do this:

 app.get("/", (req, res) => {
            console.log({" / ": true});
            request('http://localhost:8100/create-account', function (error, response, body) {
                res.json(response);
                if(error) {
                    throw error;
                }
            });
        });

Hello,

maybe you should do it without port numbers.

Best regards, anna-liebt

It looks like you are trying to post your request to the wrong url and port… Ionic usually runs on port 8100 so I’ll assume that the the node js server is port 3000. You don’t appear to have defined a post method for the node server… In the code that you provided one of the issues is that you need to create an app.post method…