Forums

OverviewFelgo 2 Support (Qt 5) › Error getting URL

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #22356

    Miguel Amaro

    Hi, I’m doing the Felgo udemy course by Grant KlimaytysChristian Feldbacher. I’m getting this error for some reason. There was an similar problem in the tut that gave the “Fatal error in URL GET” which had to do with openSSL but, I downloaded the three files and it started working. This seems to be something else.

    Where might this error be coming from? It seems like it’s successful the first time and then It’s called  a second for some reason, and fails…

    My input: london

    Felgo Live Server Output:
    GET: http://api.nestoria.co.uk/api?country=uk&pretty=1&encoding=json&listing_type=buy&action=search_listings&page=1&place_name=london
    Success parsing JSON
    Server returned app code: 100
    Fatal error in URL GET

    
    
    //I click the go button to search for "london" listings 
      AppButton {
                    text: qsTr("Go")
                    onClicked: search()
    }
    
    //The search function from Logic.qml is called
     function search() {
            logic.searchListings(searchInput.text, true)
    }
    
    
    //Logic.qml send a signal
    signal searchListings (string searchText, bool addToRecents)
    
    //Datamodel.qml receives the signal and calls client.search which calls response Callback as a parameter?? no more bool???
    Connections {
            id: logicConnection
    
            onSearchListings:{
                client.search(searchText, _.responseCallback)
            }
        }
    
    //Client.qml search..
    function search (text, callback){
            _.sendRequest({
                              action: "search_listings",
                              page: 1,
                              place_name: text
                          }, callback)
        }

     

    Item {
            id: _ //private member
            readonly property string serverUrl: "http://api.nestoria.co.uk/api?country=uk&pretty=1&encoding=json&listing_type=buy"
            property var lastParamMap: ({})
    
            function buildUrl (paramMap){
                var url = serverUrl
                for (var param in paramMap){  //Gets loops for each URL parameter and adds it the to URL String
                    url += "&" + param + "=" + paramMap[param]
                }
                return url
            }
    
            function sendRequest (paramMap, callback) {
                var method = "GET"
                var url = buildUrl(paramMap)
                console.debug(method + ": " + url)
    
                HttpRequest.get(url)
                .then(function(res){
                    var content = res.text
                    try {
                        var obj = JSON.parse(content)
                    }
                    catch (ex) {
                        console.error("Could not parse JSON", ex)
                        return
                    }
                    console.debug("Success parsing JSON")
                    callback(obj)
                })
                .catch(function(err){
                    console.debug(("Fatal error in URL GET"))
                })
                lastParamMap = paramMap
            }
        }

     

     

    #22357

    Janne

    Hi,

    You should print out the err to get more details on the problem:

    console.debug("Fatal error in URL GET: ", err)

     

    #22367

    Miguel Amaro

    haha That sound like a good idea!
    New Error msg: Fatal error in URL GET ReferenceError: listingsRecieved is not defined.

    So, It seems like spelling might be an important part of programming..

    It works! Thank you Janne!

    So, listingsReceived() must be a builtin function.

    Item {
        property alias dispatcher: logicConnection.target
    
        signal listingsReceived //Fixed! incorrectly spelled listingRecieved added the 's' and swapped the 'i' and 'e'
                                                                              |
        Client {                                                              |
            id: client                                                        |
        }                                                                     |
    ...                                                                       |
    .....                                                                     |
    .......                                                                   |
                                                                              |
     function responseCallback (obj){                                         |
                var response = obj.response                                   |
                var code = response.application_response_code                 |
                console.debug("Server returned app code: ", code)             |
                                                                              |
                if (successCodes.indexOf(code) >= 0){                         |
                    //Location found                                          |
                    currentPage = parseInt(response.page)                     |
                    listings = listings.concat(response.listings)             |
                    numTotalListings = response.total_results || 0            | 
                    listingsReceived() //Same here, swapped the 'i' and 'e' <-|
                } else if (ambiguousCodes.indexOf(code) >= 0){
                    locations = response.locations
                } else if (code === "210") {
                    locations = []
                } else {
                    locations = []
                }
            }
        }
    }

     

Viewing 3 posts - 1 through 3 (of 3 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
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support