MongoLab - 无法从DB获取对象

时间:2013-12-16 21:47:48

标签: javascript http get mlab

我想从mongolab的集合中获取一些对象,这是我的查询函数:

$scope.getMethods = function ()
    {
        var getList = $http.get("https://api.mongolab.com/api/1/databases/timeman/collections/Methods",
            { params : 
               { apiKey : apiKeyString,
                  q : JSON.stringify({ "project_id" : '"' + $scope.project_id +'"'})
               }
            }

        );
        getList.success(function(data, status, headers, config) {
            $scope.projectMethods = data;

        }); 
        getList.error(function(data, status, headers, config) {
           throw new Error("Something got wrong with get");
        });
    };

或者,我也尝试过这种方式

var getList = $http.get("https://api.mongolab.com/api/1/databases/timeman/collections/UCD_Methods?",
              + apiKeyString + '&q={"project_id":"' + $scope.project_id + '"}', {});

问题在于,在这两种情况下,地址都没有得到正确的解释:事实上,我无法检索对象,在我的浏览器的控制台中,您可以看到在“q =”之后引号被解释为这样%22(我用点替换了apiKey):

[22:39:13.951] GET https://api.mongolab.com/api/1/databases/timeman/collections/Methods?apiKey=...&q=%7B%22project_id%22:%2252aee85ae4b01e4b6836c226%22%7D [HTTP/1.1 200 OK 577ms]

有什么想法吗?

谢谢!

0 个答案:

没有答案