1

So far REST API get method working in my local ng serve , but in my device not working.

Android device remote debug showing :URL:'localhost/get/list'

proxy.config.json

"/code":{   
        "target": "http://192.x.x.x:8010",   
        "secure":false,
        "changeOrigin": true,
        "logLevel": "debug"
    },

Serive Get Method:

      this.service.getUrl('/get/list','level=2').subscribe(
        data=>{ //Android Device URL :localhost/get/list not showing proxy.config.url

});

package.json

"start": "ng serve   --proxy-config proxy.conf.json",

Remote Debug Result:**I can't get **_body result like local result , it's seems getting index.html page.

Android Remote DEBUG

Local ng Serve Result: Local

5
  • Are you running in an emulator or on your actual phone?
    – Diesel
    Commented May 15, 2019 at 3:35
  • Actual Phone as well as Emulator
    – sameer
    Commented May 15, 2019 at 4:04
  • How are you hosting your API? Who is serving it? Is it configured to allow outside connections? Does 10.0.2.2 work on the emulator?
    – Diesel
    Commented May 15, 2019 at 20:32
  • IP:10.0.2.2 not connected success , need to config from outside IP (192.X.X.X.X:8080)
    – sameer
    Commented May 16, 2019 at 4:00
  • Is 8080 open to the outside? And whatever server you are using configured to allow outside connections?
    – Diesel
    Commented May 17, 2019 at 3:09

1 Answer 1

1

If you are using the emulator and the API is on your local machine, change the IP address in proxy.config.json to 10.0.2.2. Check out How do you connect localhost in the Android emulator?

Not the answer you're looking for? Browse other questions tagged or ask your own question.