我有一项服务可以results
处理. 我将如何创建一个基本上以该特定 id 获取结果并使用结果数据创建条形图的路由。results
feathersjs
/results/:id/hr_bar_graph
我目前的代码是:
module.exports = function (app) {
const Model = createModel(app);
const paginate = app.get('paginate');
const options = {
name: 'results',
Model,
paginate
};
// Initialize our service with any options it requires
app.use('/results', createService(options));
app.use('/results/:id/hr_bargraph_image', {
find(id, params){
this.app.service('results').get(id)
.then(function(response){
console.log(response);
})
.cathc(function(error){
console.log(error);
})
return Promise.resolve({
imageData: ''
});
}
});
// Get our initialized service so that we can register hooks and filters
const service = app.service('results');
service.hooks(hooks);
};
现在被困在这里一段时间了。请帮忙。