2015-08-31 53 views
2

我有一个称为`Model.showMap'的远程方法用于我的模型,该方法由许多模型实现。但我需要在内部构建一个URL来发送电子邮件。Loopback如何以编程方式获得方法路径

如何以编程方式获取该方法?我需要这样的东西

ModelA.showMaṕ.getPath({id: XXXX, absolute: true}); // http://localhost:3000/api/ModelA/xxxx/mymap 
People.showMaṕ.getPath({id: XXXX, absolute: true}); // http://localhost:3000/api/people/xxxx/mymap 

回答

1

你应该能够得到远程处理元数据如下:

Model.sharedClass.find( 'showMap',真).http.path;

+0

感谢您的线索,将对于理解更好的回送有很多帮助,但这只会返回方法'/ mymap'的最后部分 – rkmax

0

使用林峰的答案,我会扩大有点

return [ 
    Model.sharedClass.http.path, 
    Model.sharedClass.find('showMap', true).http.path 
].join(''); //Model/mymap 

在这种情况下,解决了我的问题,但将是巨大的,如果环回支持这也是缺省参数传递

相关问题