node.js - Angular-sails 中的 POST/GET 请求

标签 node.js angularjs sails.js

我正在使用angular-sails在我的项目中,我在从 Angular Controller 发送 POST 或 GET 请求时遇到问题。这是我的 Controller :

Angular:UserController.js

myApp.controller('UserCtrl', function ($scope, $sails) {
    $sails.post('/addUser', {name: 'test'}, function (response) {
        console.log(response);
    });
});

在 sails 服务器端 Controller 中,我有:

Sails:UserController.js

module.exports = {
    addUser: function(req, res) {
        //SQL query
        return res.json({success: true});
  },
  _config: {}
};

在我的 route :

Sails:routes.js

module.exports.routes = {
    'post /addUser': {
        controller: 'UserController',
        action: 'addUser'
    }
}

访问网址:localhost:1337/addUser直接给我:

{success: true}

但是,从 Angular Controller 发出 post/get 请求不会执行任何操作。

可能是什么问题?

--

解决方案:将 Angular-sails 更新到 v0.1.3 版本即可解决该问题。

最佳答案

将 angular-sails 更新到版本 v0.1.3 将解决该问题

关于node.js - Angular-sails 中的 POST/GET 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22483510/

相关文章:

javascript - 如何将多值变量传递给 AngularJS 指令

javascript - 在 AngularJs 中单击时选择和取消选择所有复选框

javascript - AngularJS:输入类型=数字“将 ngModel 字符串值解析为数字并返回

javascript - sails.js 中的某些 URL 可以免除 CSRF 吗?

node.js - 使用jade创建无序列表树

node.js - 让Nodejs脚本通过eth0发出http请求:0 and eth0:1

node.js - 尝试在 Node.js 服务器中连接 Google Earth Engine API 时出错

node.js - NodeJS 集群模块

node.js - Sails JS - 删除现有的 JWT

javascript - MongoError : topology was destroyed sailsjs