I just want to read my data in an Object and print multiply buttons in a row.
How could I do that?
A similar example :
var obj={"coca":"2$" , "7up":"3$" , "fanta":"4$"}
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
ctx.reply('price list', Extra.HTML().markup((m) =>
m.inlineKeyboard([
[m.callbackButton(`${key} : `, ` price : ${obj[key]}`)]
]))))
But the problem is I do not want to print "price list" every time.
I just want to print it 1 times on top, and I can not use for loop inside "ctx.reply"
If you just want the first item to be replied, all you have to do is to break the loop after first reply.
Your code may be like this:
var obj={"coca":"2$" , "7up":"3$" , "fanta":"4$"}
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
ctx.reply('price list', Extra.HTML().markup((m) =>
m.inlineKeyboard([
[m.callbackButton(`${key} : `, ` price : ${obj[key]}`)]
]))));
break;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With