admin管理员组文章数量:1414908
I have a web mini app in Telegram.
I send data back to bot by function:
const notifyBotAndClose = async () => {
if (window.Telegram && window.Telegram.WebApp) {
console.log("Telegram WebApp API is available");
} else {
console.log("Telegram WebApp API is NOT NOT available");
}
try {
window.Telegram.WebApp.ready();
window.Telegram.WebApp.sendData(JSON.stringify({ command: "start" }));
sdk.close(); // Closes the mini app
} catch (error) {
console.error("Error sending /start:", error);
}
};
I can see localy that its sending:
Telegram WebApp API is available
telegram-web-apps.js:135 [Telegram.WebView] > postEvent web_app_ready
telegram-web-apps.js:135 [Telegram.WebView] > postEvent web_app_data_send {data: '{"command":"start"}'}
I try to catch it on backend of bot
@router.message()
async def get_web_app_data(message: types.Message):
print(message.__dict__)
if message.web_app_data:
print(f"Received WebApp data: {message.web_app_data.data}")
await message.answer(f"Received WebApp data: {message.web_app_data.data}")
else:
print("No WebApp data")
print(message.__dict__)
and cannot see nothing. How can I debug it?
本文标签: javascriptWeb mini app in Telegram send data no responceStack Overflow
版权声明:本文标题:javascript - Web mini app in Telegram send data no responce - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745159129a2645355.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论