javascript - Web mini app in Telegram send data no responce - Stack Overflow

I have a web mini app in Telegram.I send data back to bot by function:const notifyBotAndClose = async

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745159130a4614304.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信