无法在Loopback中仅针对一个URL对'XMLHttpRequest'执行'send'

时间:2016-06-15 10:14:53

标签: xmlhttprequest loopbackjs strongloop

Strongloop / Loopback node.js服务器与'ng-admin'编辑器和sqlite db一起使用。我需要获得实体数量:

  var Httpreq = new XMLHttpRequest();
  Httpreq.open('GET', yourUrl, false);
  Httpreq.send(null);
  return Httpreq.responseText;

其中yourUrlhttp://localhost:3000/api/v1/entity/count类似。

除了名为“广告”的实体之外,所有网址都有效,我有angular.js:12783 Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load http://localhost:3000/api/v1/advertisement/count。此网址适用于API资源管理器。

Advertisement.json:

{
  "name": "Advertisement",
  "base": "EntityBase",
  "plural": "Advertisement",
  "options": {
    "validateUpsert": true,
    "sqlite3": {
      "table": "advertisement"
    }
  },
  "properties": {
    "name": {
      "type": "string",
      "required": true
    },
    "category_id": {
      "type": "number"
    },
    "due_date": {
      "type": "string"
    },
    "from_date": {
      "type": "string"
    },
    "phone": {
      "type": "string"
    },
    "site": {
      "type": "string"
    }
  },
  "validations": [],
  "relations": {
    "category": {
      "type": "belongsTo",
      "model": "Category",
      "foreignKey": "category_id"
    },
    "photos": {
      "type": "hasMany",
      "model": "Photo",
      "foreignKey": "advertisement_id"
    }
  },
  "acls": [],
  "methods": {},
  "mixins": {
    "Timestamp": {},
    "SoftDelete": {},
    "GenderAge": {},
    "Descripted": {}
  }
}

1 个答案:

答案 0 :(得分:0)

将实体重命名为Commercial以解决此问题。