How to point to localhost:8000 with the Dart http package in Flutter?

前端 未结 9 1086
野趣味
野趣味 2020-12-10 00:34

I\'m following the Flutter Networking/HTTP tutorial to do a GET request to a server running on my localhost:8000. Visiting my localhost via my browser works fine. My code lo

9条回答
  •  無奈伤痛
    2020-12-10 01:14

    If you are trying to access localhost api through emulator, Change localhost to your IPV4 Address. And if you are running your api in Visual Studio set the app URL also to be IPV4 address. In my case I changed it from "localhost:5001" to 192.168.XX.XX:5001

    if you don't change the backend it will return “Bad Request-Invalid Hostname” When accessing localhost from emulators

提交回复
热议问题