我的firebase db上有一个超过11个病人的名单,我想做的是加载前5个病人。但我的问题是,当我单击下一个按钮时,它会重新加载页面,这是我的脚本。但是当我放在/:next
我的端点上时,脚本不起作用。但是当我删除它时,它会加载前 5 个数据,但是当我单击下一个按钮/上一个按钮时,它只是重新加载页面。
router.get('/host/:next', function (req, res) {
var ref = database.ref('patients').limitToFirst(5);
var quickReplies = {
messages: [
{
text: "select now..",
quick_replies: []
}
]
};
var backButton = {
"set_attributes":{
"next":-1
},
"title":"\u23ea",
"next":"0",
"block_names":["list"]
};
var nextButton = {
"set_attributes":{
"next":1
},
"title":"\u23e9",
"next":"0",
"block_names":["list"]
};
ref.once('value', function (snapshot) {
snapshot.forEach(function (childSnapshot) {
var childKey = childSnapshot.key;
var childData = childSnapshot.val();
var setAttr = {
set_attributes: {
title: childData.firstName,
next: 0
},
title: childData.firstName,
next: 0,
block_names: ['na']
};
quickReplies.messages[0].quick_replies.push(setAttr);
});
quickReplies.messages[0].quick_replies.unshift(backButton);
quickReplies.messages[0].quick_replies.push(nextButton);
res.send(quickReplies);
});
});
这是我的 json 获取请求..localhost:8100/api/users/host?next={{next}}
下一个的默认值为 0..