环回远程方法路径定义问题

loopback remote method path definition issue

我想用以下路径定义一个远程方法:

http://localhost:3000/api/dataSourceTestings/{id}/a

In the dataSourceTesting.json file I defined its path as :
"http": [
        {
          "path": "/{id}/a",
          "verb": "put"
        },
]

But when I send request on this end point it gives me the error that can't found the method for this endpoint. 

我需要为它定义一个关系还是有任何其他方法可以为这个路径定义一个远程方法?

您应该在 dataSourceTesting.js 文件中定义您的远程方法:

DataSourceTesting.remoteMethod('putDataSourceTestings', {
    accepts: [
        {arg: 'id', type: 'string'}],
    http: {path:'/:id/a', verb:'put'},
    returns: {arg: 'result', type: 'json'}
});

然后实现您的 putDataSourceTestings 函数:

DataSourceTesting.putDataSourceTestings = function(id, cb){
    //your logic goes here
}

与此问题相关的博客:

https://strongloop.com/strongblog/remote-methods-in-loopback-creating-custom-endpoints/