Cordova - the API level 31 is causing issues with the this.http.get() requests, which were previously functioning properly in API level 30

Hey friends, I'm facing an issue with Cordova 10.1.2. When I update the API level from 30 to 31 in the config.xml file:

This particular code isn't functioning as expected

  
$.ajax({
    url: "#URL"
    , type: 'GET'
    , async: false
    , success: function (result) {
        LOGGER.info('result ', result);
    }
    , complete: function (xhr, status) {
       
    }
});

HTTP requests are not working, but HTTPS is fine. Can someone please assist me in making HTTP work properly?

Answer №1

It appears that support for HTTP was initially dropped in cordova-android-10.0.0, but then reinstated in cordova-android-10.1.0. To enable this feature, you must explicitly add the following preference to your config.xml file:

<preference name="scheme" value="http" />

For more information and updates on these changes, please refer to the documentation:

If HTTPS is already functioning properly, it may be worth considering why you still need to use HTTP.

Additionally, exploring the fetch API as a modern alternative could be beneficial. You can learn more about it here: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API. This offers a more contemporary approach to handling data retrieval.

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

retain the input data from the form by using the keyup event

Currently, I have a scenario where an input field is used to capture user input. Instead of displaying the entered value directly, I am looking to store it in a variable and subsequently use it to retrieve data from a database. Below is the code snippet I ...

The AJAX success callback function failed to execute in cases where the dataType was set to JSONP during Cross domain Access

type = 'math'; var ajurl = "sample.com&callback=myhandler"; var datas = "cateid=" + cateid + "&type=" + type + "&pno=" + pno + "&whos=" + whos; $.ajax({ type: "GET", url: ajurl, data: datas, contentType: "application/json; ...

Leveraging Promises within if conditions

Has anyone encountered difficulties using Promises within an if condition? I'm currently dealing with a problem where the code continues to execute even when the if statement is false. Any suggestions on how to resolve this issue? For a detailed exam ...

"Encountering an issue with supabase.auth.getUser() when implementing a vue-router route guard

My Vue application project involves integrating Supabase authentication. In one of the route guards within the router file, I used supabase.auth.getUser() to determine the user's login status and control the execution flow based on that condition: // ...

How can one ensure efficient execution of heavy JavaScript tasks without causing any blocking issues?

Currently, I'm utilizing webgl to load a 3D model and running some code to manipulate it before displaying it. The issue is that this process takes several seconds and completely restricts the user from performing any other tasks during that time. It ...

The custom validation function in jQuery is not triggering

I am facing an issue with my HTML and JavaScript setup, which looks like this: <html> <head> <title>Validation Test</title> <script src="https://code.jquery.com/jquery-3.4.1.js"></script> <script src="htt ...

Collect all wallet objects and store them in an array of objects within BitGO for Bitcoin

My Setup: Using the Mongoose module to handle all MongoDB operations, we generate and store a wallet inside a Mongo collection for each new user. METHOD: By using User.find({}, function(err, docs) {, we can retrieve each user object. User.find({}, functi ...

Unable to conceal a div that was generated by Javascript

I have a basic HTML webpage. <!DOCTYPE html> <html lang="en> <head> <meta charset="UTF-8> <title>TEST</title> <script type="text/javascript" src="https://externalsite.com/script.js" async=true> </scri ...

Iterating over JSONObject to Form Array in Java

I am currently working with a JSONObject in the following format: [{"ascii_name":"Rio de Janeiro"},{"ascii_name":"Riyadh"},{"ascii_name":"Rome"},{"ascii_name":"Rawalpindi"},{"ascii_name":"Rabat"},{"ascii_name":"Recife"},{"ascii_name":"Ra's Bayrut"}, ...

Accessing a model's field within an Ember.js each loop

Here is the code for a route that I am working on: Calendar.DateIndexRoute = Ember.Route.extend({ model: function(data) { return {arr:getCalendar(data), activeYear: data.year, activeMonthNumber: data.month, activeDay: data.da ...

Customizing Body Color in CKEditor for Dynamic Designs

I am facing an issue with CKEditor that I am hoping to find a solution for. My scenario involves using a jQuery color picker to set the background color of a DIV element, which is then edited by the user in CKEditor. However, I have observed that it is not ...

What is the best way to share image data between pages in Next.js?

I'm currently developing a project that mimics Instagram (simply because I want to explore Next.js further) and I'm looking for a way to handle image uploads. My goal is to allow users to upload their images and then redirect them to the "create ...

At what point is arr[ i ] added to the new array (flat) when flattening an Array - through flat.push() or flat.concat()?

I grasp the concept, but I am struggling to understand the process. Once it reaches this line: flat = flat.concat(flatten(arr[i])) I fail to comprehend how that specific subarray which is about to be iterated through ends up in flat = []. I realize t ...

Creating an inverted curve or border-radius for a div element is a design technique that can add

I've been tackling a project that requires me to style the border of a div in an inverted manner. To achieve this, I'm limited to using only CSS and JS without any plugins. I've searched through various online resources and similar questions ...

My Discord.JS bot seems to be moving at a snail's pace, and I can

Apologies for the lackluster title, I'm struggling to come up with something better. I'm currently running a self-bot (I understand it goes against the terms of service but I'm experimenting) that needs to download new files (specifically i ...

Utilizing React to customize JVectorMap markers

Having an issue with a marker appearing in my React project https://i.stack.imgur.com/hkqnZ.jpg The markers are displaying correctly, but there is a persistent initial marker at 0,0 that I can't remove. Removing the 'markers' property from ...

GET method encounters error with date parameter, displaying 'Invalid Date'

I have encountered an issue with a date string being passed as a query parameter in a GET method. When the string is hardcoded and converted using new Date(date) method, it works perfectly fine. However, when trying to do the same with the query parameter, ...

Tips for ensuring an element is visible in CUCUMBER JS?

Whenever I run my code, it keeps returning the error message: NoSuchElementError: no such element: Unable to locate element Even though I have set up a wait function, it does not seem to actually wait. The step fails immediately without waiting for the s ...

Delay the occurrence of a hover effect until the previous effect has finished executing

As I hover over an element, the desired animation is displayed while hiding other elements on the page. The challenge I'm encountering is that if I quickly hover over many divs, the animations queue up and hide the divs sequentially. I want only one ...

Encountering a TypeError when utilizing a npm hashtable within an object definition

I am currently working on setting up a basic stream to read and parse JSON data and then add key-value pairs to a hashtable. My end goal is to create a module that can be utilized in another program, but as I'm troubleshooting, I've hit a roadblo ...