如何让我的数据库在我执行api调用时不追加状态?

所以我正在尝试使用MEAN堆栈创build一个简单的博客应用程序。 我能够成功地写入我的本地mongo数据库,但是当我打电话给我的数据库时,它附加了额外的信息到我的查询,这使得很难重复。 以下是响应的样子:

[{"_id":"135","title":"aaaaaa","body":"aaaaaa","__v":0,"posted":"2017-08-05T08:46:27.159Z"}, {"_id":"136","title":"bbbbb","body":"bbbbb","__v":0,"posted":"2017-08-05T08:46:40.232Z"}] 200 function (d){b||(b=vd(a));return d?(d=b[Q(d)],void 0===d&&(d=null),d):b} {"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/api/blogpost","headers":{"Accept":"application/json, text/plain, */*"}} OK 

我只想在对象中使用“aaaa”和“bbbb”的前两个元素,所以我可以使用ng-repeat来获取标题,正文等。这就是我在index.html中显示信息的方式:

 <input ng-model="post.title" class="form-control" placeholder="title"> <textarea ng-model="post.body" class="form-control" placeholder="body"></textarea> <button ng-click="createPost(post)" class="btn btn-primary btn-block">Post</button> <div ng-repeat="post in posts"> {{post}} </div> 

以下是我的Angular获取代码的外观:

  function getAllPosts() { $http({ method: 'get', url: '/api/blogpost' }).then( function (posts){ $scope.posts = posts; }, function (error){ console.error("Inside app.js._getAllPosts().error"); }); } 

这是我的后端:

 app.get("/api/blogpost", getAllPosts); function getAllPosts(req, res) { var post = req.body; PostModel .find() .then( function (post) { res.json(post); }, function (error) { res.sendStatus(400); } ); } 

如果需要,我可以发布我的代码的其余部分。

我认为你只需要引用你的成功callback data属性:

 }).then(function(response) { $scope.posts = response.data; 

使用密钥名称来访问特定的对象。

 <div ng-repeat="post in posts"> {{post.title}} {{post.body}} </div>