环回外部api错误

时间:2015-12-10 07:08:04

标签: javascript node.js loopbackjs

我在loopback上创建了我的外部api,我试图使用Model.find方法和其他查询方法,它不适合我,我得到的只是错误信息。

以下是我得到的消息 the error i get

我检查后可能是我的api结果问题,因为我的对象在另一个对象内。 my api output

有人可以指导我如何解决它,可以改变输出结果吗?

datasources.js

"consumer_model": {
"name": "consumer_model",
"connector": "rest",
"debug": "false",
 "operations": [
   {
     "template": {
       "method": "GET",
       "url": "http://myurl.com/api/v1/consumers",
        "headers": {
          "accepts": "application/json",
          "content-type": "application/json"
        },
        "query": {
          "id": "{id}",
          "firstname": "{firstname}"
        },
        "responsePath": "$.data"
      },
      "functions": {
        "consumer": [
          "id",
          "firstname"
        ]
      }
    }
  ]
}

模型config.js

"consumers": {
"dataSource": "consumer_model",
"public": true
}

myconsumer.js

module.exports = function(consumers) { 

};

myconsumer.json

{
 "name": "consumers",
 "base": "Model",
 "idInjection": true,
 "options": {
   "validateUpsert": true
 },
 "properties": {},
 "validations": [],
 "relations": {},
 "acls": [],
 "methods": {}
}

0 个答案:

没有答案