OverviewFelgo 2 Support (Qt 5) › Infinite loop when doing multiple HttpRequest


Viewing 1 post (of 1 total)
  • Author
  • #23355



    I am very new to QML and programming in general. I am trying to build a private app for my home automation system.


    I built an HTTP REST client to fetch data from an API. It works pefectly for one request, but when I use the client function twice on the same page, it keeps recalculating both functions endlessly…


    Here is my client code:

    QtObject {
            id: _
            readonly property string apiUrl: "XXX"
            readonly property string apiKey: "XXX"
            property string jsonData: "null"
            property string value: "null"
            //property string collectdate: "null"
            function post(method, cmdid) {
                .set('Content-Type', 'application/json')
                          "jsonrpc": "2.0",
                          "method": method,
                          "params": {"id":[cmdid],"apikey": apiKey}
                .end(function(err, res) {
                    if(res.ok) {
                    jsonData = JSON.stringify(res.body.result)
                    var keys = Object.keys(res.body.result)
                    //console.log("keys= " + keys)
                    var keyid = keys [Object.keys(keys)[0]]
                    //console.log("keyid= " + keyid)
                    value = JSON.stringify(res.body.result[keyid].value)
                    //console.log("valeur= " + value);
                    var collectdate = JSON.stringify(res.body.result[keyid].collectDate)
                    //console.log("date de collecte= " + collectdate);
                    //return value
                    else {
                return value
        function execCmd(cmdid) {
            console.log("methodtype", cmdid))
            return"methodtype", cmdid)


    And my page code:


            id: api
        AppText {
            text: "Salon : " + api.execCmd(#CMDID_1#) + "°C"
            anchors.centerIn: parent
        AppText {
            text: "Bureau : " + api.execCmd(#CMDID_2#) + "°C"


    So if I have only one AppText (one CMD_ID), it works fine. But with two CMD_ID, I have an infinite loop on both console and display.


    I also tried with Promise, same result…


    I have the feeling that I am missing a very simple programming concept…


    Thanks a lot for your help

Viewing 1 post (of 1 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support