1

I am developing an application in android using cordova and angularjs (onsenui front end framework). Here is my get request to fetch some data from server

$http.get(url+"getlotterylist").then(function(msg){
        $scope.loading=false;
        $scope.items=msg.data;
    },
    function(err){
        alert("error"+JSON.stringify(err));
          console.log("Error"+JSON.stringify(err));
        }
    );

CASE 1

When running app in browser i will get the desired output (get request works fine).

CASE 2

Build my app in android platform and import to android studio. At this point the http get request returns the following error

{"data":"","status":404,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"http://example.com?action=getlotterylist","headers":{"Accept":"application/json, text/plain, /"}},"statusText":"Not Found"}"

Also enabled CORS in my php

<?php

  header("Access-Control-Allow-Origin: *");
 //api request response
?>

Why i am getting this error when running my app in phone?

1 Answer 1

8

Installing Cordova white-list plugin solves my problem

https://github.com/apache/cordova-plugin-whitelist

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I ran into the same problem and was getting quite frustrated.Adding t he white list plugin solved for me too.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.