简体   繁体   English

使用Restangular进行GET通话

[英]GET call using restangular

I'm trying to use the GET method using Restangular to get some objects back from the backend using a rest call. 我正在尝试使用使用Restangular的GET方法通过rest调用从后端获取一些对象。

its a simple GET call..not sure why im getting an error. 它是一个简单的GET调用..不确定为什么我得到一个错误。 if someone can point out something im missing that would be great. 如果有人可以指出我所缺少的东西那就太好了。

my restangular call: 我的矩形电话:

        var vm = this;
        vm.getEvent = function() {
            Restangular.one('/services/v1').one('people').get();
        }

object i should be getting back looks like this: 我应该回来的对象看起来像这样:

[
  {
    "id": 1,
    "name": "string",
    "description": "string",
    "locations": [
      {
        "id": 1,
        "name": "string",
        "description": "string"
      }
    ]
  },
  {
    "id": 2,
    "name": "string",
    "description": "string",
    "locations": [
      {
        "id": 2,
        "name": "string",
        "description": "string"
      }
    ]
  },
  {
    "id": 3,
    "name": "string",
    "description": "string",
    "locations": [
      {
        "id": 2,
        "name": "string",
        "description": "string"
      }
    ]
  }
]

Getting this error when i call it in html: 当我在html中调用它时出现此错误:

Error: [$rootScope:infdig] 10 $digest() iterations reached. 错误:[$ rootScope:infdig]达到10个$ digest()迭代。 Aborting! 流产! Watchers fired in the last 5 iterations: [] 观察者在最近5次迭代中被解雇:[]

EDIT: 编辑:

endpoint 终点

http://localhost:3000/services/v1/people http:// localhost:3000 / services / v1 / people

your code should be as below 您的代码应如下所示

var vm = this;
    vm.getEvent = function() {
        Restangular.one('/services/v1').get('people').then(function(data){console.log("data",data)});
    }

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

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