我有2个现有端点/balance /transactions
创建新的/balance-and-transactions
而不重写现有代码的最佳方法是什么?
例如:
a('/balance', () => {
foo()
res.send({ /*some json with balance */ });
});
b('/transactions',() => {
boo();
res.send({ /*some json with transactions */ });
});
newendpoint('/balance-and-transactions', () => {
foo();
boo();
res.send({ /*some combined json with balance and transactions altogether */ });
});
在newendpoint(内部调用)中调用2个请求是一个好主意吗?
newendpoint('/balance-and-transactions', () => {
data1 = request('/balance');
data2 = request('/transactions');
// then combine data1 and data2
res.send({ /*some combined json with balance and transactions altogether */ });
});
答案 0 :(得分:0)
合并这些端点不是一个好主意,但是如果您仍然想这样做,最好使用破折号而不是下划线mix
.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.version();