flutter get request failed with error _ClientSocketException (Connection refused)

问题描述 投票:0回答:0

我有这段代码,正在尝试从我的服务器(正在侦听端口 3000)获取数据。虽然它失败并出现此错误,但我不知道如何修复它。我试过 NGROK 生成一个转发地址,但返回了一个连接被拒绝的错误。这是我的代码:

Future<String> LoadData() async {
  //Load data for home screen
  //First load featured data
  final featured = await http.get(Uri.parse('localhost:3000/featured'));
  final news = await http.get(Uri.parse('http://localhost:3000/news'));
  print(news);
  print(featured);
  return 'something';
}

谢谢!

android ios flutter dart get
© www.soinside.com 2019 - 2024. All rights reserved.