Having trouble with Axios on Android after compiling with Phonegap?

I'm facing an issue with my Phonegap .apk file after building it on their platform. The problem lies with axios not functioning properly, although it works fine in my Desktop Phonegap App. I'm unsure of the root cause behind this, could it be related to the usage of axios?

Technologies: Axios , VueJS , Phonegap

This is how my index.js appears:

Vue.directive('focus', {
    inserted: function(el) {
        return el.focus();
    }
});

var apiURL = 'http://stishs-grade-and-progress-report-monitoring-system.cf/',
    tokenString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';

var Authentication = Vue.component('sti-main', {
    data() {
        return {
            username: '',
            password: '',
            error: {
                flag: false,
                message: ''
            }
        }
    },
    template: `
        <main>
            /* code block truncated for brevity */
        </main>
    `,
    created: function() {
        var authToken = localStorage.getItem('stishTokenAPI')
        if(authToken != null && authToken.split('&')[2] == 3) {
            var authData = `method=check&0=${authToken.split('&')[0]}&1=${authToken.split('&')[1]}`
            return axios.post(`${apiURL}sti-api/authentication.php`, authData).then(function(response) {
                var authenticated = response.data
                /* additional logic here */
            });
        }
    },
    methods: {
        hideNotif: function() {
            return this.error.flag ? this.error.flag = false : true
        },
        generateToken: function(generateToken = '') {
            /* code block truncated for brevity */
        },
        signInProceed: function(user, pass) {
            /* code block truncated for brevity */
        }
    }
});

new Vue({
    el: '#auth'
});

This is the structure of my index.html:

<!DOCTYPE html>
<html>
    <head>
        /* code block truncated for brevity */
    </body>
</html>

This is how my config.xml looks like:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>sti-mobile-app</name>
    <description>
        A blank PhoneGap app.
    </description>
    <author email="[email protected]" href="http://phonegap.com">
        PhoneGap Team
    </author>
    <content src="index.html" />
    <allow-navigation href="*" />
    <allow-intent href="*" />
    <access origin="*" />
</widget>

Answer №1

When developing Android or PhoneGap apps, it is essential to specify the domains that you want to access. This could be the issue you are running into.

You may find this cordova plugin useful:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting the issue with Protractor/Jasmine test when browser.isElementPresent does not detect a class in the

As a newcomer to Jasmine testing, I've been facing some challenges while running my tests. Specifically, I have been struggling with my webdriver closing the browser before it can check the '.detailsColumn' element for expected results. Afte ...

template for displaying data in Vue.js using props

In my application, I have a component that I frequently use to display tables. Now, I want to enhance this component by allowing the customization of table fields (templates) through props in the parent component. This way, I can avoid constant edits to th ...

State management through Functional Reactive Programming

Many believe that FRP involves managing event streams without the need to explicitly handle state. An example of this can be found here: Others argue in favor of FRP by highlighting the challenges associated with programming solely through side-effects, a ...

Creating multiple div elements with changing content dynamically

I am facing an issue with a div named 'red' on my website where user messages overflow the 40px length of the div. To prevent this, I want to duplicate the 'red' div every time a message is sent so that the messages stay within the boun ...

Tips on linking a changing object using v-bind in Vue

Can someone help me with a query regarding the v-bind dynamic object? When dealing with binding in a completely dynamic object, how can I bind properties using operation expressions? How can I ensure that the attributes stay observable and update automatic ...

Fill out a Form in a separate Tab multiple times

I'm currently developing a straightforward form for distributing a newsletter: <form method="post" id="newsletter_form" action=""> <label for="subject">Newsletter Subject:</label><br/> <input type="text" nam ...

Set up npm and package at the main directory of a web application

Currently, I am in the process of developing a web application using node.js. Within my project structure, I have segregated the front-end code into a 'client' folder and all back-end logic into a 'server' folder. My question revolves a ...

Retrieving InnerHTML of a Rendered DOM Element in AngularJS

Can I retrieve the innerHTML code of a rendered element that contains an ng-repeat loop? Here is an example: <div id="container"> <div ng-repeat="e in ctrl.elements>{{e.name}}</div> </div> ...

Can a variable declared in wdio.conf be accessed?

Within the wdio.conf file, I have implemented a function called onPrepare where I am storing all my feature files in an array. let listOfFiles = fs.readdirSync(process.cwd() + '/features'); var featureFiles = []; listOfFiles.map((file) => { ...

How to delete the final character from a file stream using node.js and the fs module

My current project involves using node.js to create an array of objects and save them to a file, utilizing the fs library. Initially, I set up the write stream with var file = fs.createWriteStream('arrayOfObjects.json'); and wrote an opening brac ...

Guide on creating multiple instances of vue-multiselect with a simple button click

I am trying to implement a vue-multiselect dropdown with the addition of a new dropdown upon clicking an "add more" button. However, I am currently unsure of the best approach to achieve this. Problem/Question: When adding 2 dropdowns, if the same option ...

Exploring node.js: How to extract elements from a path

I have an array of individuals as shown below: individuals = ['personA', 'personB', 'personC']; I am looking to create a dynamic way to showcase each individual's page based on the URL. For instance, localhost:3000/indi ...

Merge text inputs to preview content prior to form submission

I've been on the hunt for a solution to display the collective values entered into multiple text box fields as they are being typed. Currently, I have 6 text boxes (description1, description2, description3, description4, description5, description6) wh ...

Is the Messenger Bot ignoring random users?

I am facing an issue that I need help explaining. The bot works perfectly when I use it from my own Facebook account. However, when I ask others to use it, the bot does not respond to them, even though I have received a green tick on the pages_messaging a ...

Having trouble importing zone.js in Angular 14 and Jest 28

I am currently in the process of updating to Angular 14. Everything is going smoothly except for setting up jest. Since I have Angular 14 libraries included in my build, I need to utilize jest-ESM support. Below is my configuration: package.json { &qu ...

Heads up in vue-router 3.5.1: Starting with Vue Router 4, the v-slot API will automatically enclose its content within an <a> tag

When utilizing "vue": "^2.6.12" and "vue-router": "^3.5.1", I am encountering a warning message every time the page reloads: [vue-router] In Vue Router 4, the v-slot API will by default wrap its content with an &l ...

Launch all external links in Browser (NWjs)

While attempting to create my own independent version of Google Chat using NWjs, I encountered some obstacles. When a link is opened in the NWjs window, it opens in another NWjs window instead of the default system browser, which is what I want. I attemp ...

JavaScript method of retrieving an object inside an array nested within another object via multer

Below is my custom multer function to handle file uploads - const storage = multer.diskStorage({ destination: (req, file, callback) => { let type = req.params.type; let path = `./data/${type}`; fs.mkdirsSync(path); callback(null, path) ...

bxSlider adds in an empty slide after deleting an image

Whenever I click a link in my navigation, I want to remove certain images from the page. I tried implementing a solution, but now I have two empty spaces where the images used to be. How can I remove those as well? I searched on Stack Overflow for a soluti ...

Trick to enable editing in Bootstrap Select Combobox

Is there a way for users to add their own options to bootstrap-select? Greetings! I have spent some time searching for a straightforward solution that is compatible with Bootstrap 4 styling. Despite exploring various suggestions, as well as unresolved thr ...