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? Commented May 15, 2019 at 3:35
  • Actual Phone as well as Emulator 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? 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) Commented May 16, 2019 at 4:00
  • Is 8080 open to the outside? And whatever server you are using configured to allow outside connections? 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?

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.