繁体   English   中英

科尔多瓦+ angularjs + nodejs(Express)$ http json总是得到404

[英]cordova + angularjs + nodejs(Express) $http json always get 404

我正在使用cordova + angularjs + nodejs(Express)在android环境中进行测试。 现在,我试图通过$ http()获取一些数据,但是我总是收到404错误(通过以下警报)。

客户代码(AngularJs)

        $http({
            method  : 'POST',
            url     : "http://192.168.1.4:8888/login",
            data    : ""
        })
        .success(function(data, status, headers, config) {
            alert("success");
            alert(data);
        })
        .error(function(data, status, headers, config) {

            alert("error");// <== always gets here
            alert(status); // <== 404
        }).
        finally(function() {
          alert("finally");
        });

服务器代码(NodeJs + Express)

...
app.get('/login',function(req, res){ 
    res.set({'Content-Type':'application/json','Encodeing':'utf8'});  
    res.json({name:"jj"}); 
}) ;
app.listen(8888); 

我可以通过Chrome访问http://192.168.1.4:8888/login来获取json字符串, 通过浏览器访问服务器,返回200

我搜索了很多东西,但仍然无法解决我的问题,有人可以帮忙吗?

http方法是post,它需要被获取。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM