离子对nodeJS的请求

时间:2019-02-14 21:58:18

标签: node.js ionic-framework post get ionic4

我正在这样向我的nodeJS服务器发出发布请求。

因此,每当我单击按钮时,它都会发布带有JSON的帖子: 如果我用console.log的JSON格式给我很好的参数,那不是问题。

 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);
        });

从我的server.js中,我这样做是为了获得帖子,但我得到了

  

POST http://localhost:3000/ 404(未找到)

在我的服务器端,我这样做:

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

我也尝试了url:http:localhost:8100 / create-account,但这也行不通,所以没有人有办法解决这个问题,似乎无法弄清楚,我对nodeJS很陌生

0 个答案:

没有答案