Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › HttpRequest::abort()

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22751

    Alberto

    I am having struggle trying to abort an HttpRequest.

    So is this possible at all?

    No matter what I try, saving the request on a variable, chaining .abort() method directly, I keep getting the same message:

     

    TypeError: Property 'abort' of object com::cutehacks::duperagent::Promise(0x1a0b97a8) is not a function

    Thanks

    #23220

    Alex
    Felgo Team

    Hi Alberto,

    Can you please share a short code example for which the abort() method does not work for you?

    Thanks,
    Alex from Felgo

    #23221

    Alberto

    Hi Alex,

    Here you are, maybe I’m misunderstanding something

     

    function fetch(){
    
            const request = HttpRequest.get('http://jsonplaceholder.typicode.com/todos/')
            .then(function(res){
                console.log(JSON.stringify(res.body))
            })
            .catch(function(err){
                console.log(err)
            })
    
            // Here, "abort" is not a function of "request"
            request.abort()
    
        }

     

    #23226

    Alex
    Felgo Team

    Hi Alberto,

    You are actually storing the Promise returned from .then().catch() to request, not the request itself. Please try the following example:

     

      function fetch() {
        var request = HttpRequest.get('https://google.com')
    
        request.then(function(res) {
          console.log(res)
        }).catch(function(err) {
          console.log(err)
        })
    
        request.abort()
      }

     

    #23227

    Alberto

    Brilliant, thank you Alex

Viewing 5 posts - 1 through 5 (of 5 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded