No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Axios request getting cancelled in android

    Help
    2
    6
    415
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      technowebs last edited by

      I build an application in quasar, which is working fine in browser. But, my android debug app it’s not working. The app has a login form, in the very 1st step. The api call is not working as the request is getting cancelled. I have connected my device using chrome remote device option, and it’s saying request cancelled. Any suggestion will be helpful, as it’s my 1st mobile app.

      1 Reply Last reply Reply Quote 0
      • Hawkeye64
        Hawkeye64 last edited by

        Is the request to a backend server somewhere on the internet?
        Are you making the correct call (GET, PUT, POST, etc) for the receiving api?
        With mobile, is this reqired to be https?
        I don’t do mobile, so don’t know. Just throwing some things out.

        1 Reply Last reply Reply Quote 0
        • T
          technowebs last edited by technowebs

          Hi @Hawkeye64, It’s requesting to a live server with a valid SSL certificate. Also, I have implemented correct methods(GET, PUT, POST etc.). The app is working perfectly when I am testing it from any web browser, there must be something wrong in the mobile part.

          1 Reply Last reply Reply Quote 0
          • T
            technowebs last edited by

            Finally I was able to find out the issue, the request was failing due to some issue in Axios interceptor, which occurring only in android

            1 Reply Last reply Reply Quote 1
            • Hawkeye64
              Hawkeye64 last edited by

              @technowebs Ouch! I use axios interceptors too. Very convenient, but can also give you a lot of grief trying to track it down if there’s an issue in one.

              T 1 Reply Last reply Reply Quote 1
              • T
                technowebs @Hawkeye64 last edited by

                @Hawkeye64 Here is the code I have written in the interceptors,

                axios.interceptors.request.use(function(config) {
                   // Get the token from session storage
                   var token = SessionStorage.getItem('token');
                
                   // Check valid token
                   if (token === null) {
                       let publicPath = ['#/login', '#/forget-password'];
                    
                       // Redirect to Login if login required
                       if (publicPath.indexOf(window.location.hash) === -1) {
                           window.location.href = '/#/login'
                       }
                    
                    } else {
                       // Set token
                       token = JSON.parse(token)
                       if (token) {
                           config.headers.Authorization = 'Bearer ' + token
                       }
                    }
                    return config;
                });
                

                The problem was occurring due to the property window.location.hash, which is returning different values in mobile(now checking with android only).

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post