如何在我的 flutter 应用程序中从共享托管服务器获取数据?

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

我无法从 flutter 应用程序中的主机共享服务器获取数据,但我可以在 PostMan 中获取它们,它可以通过 Xampp 在本地托管上运行,但我无法从我的服务器获取任何数据。

以下是几点:

邮递员结果(ok 200)

postman result

Flutter 无法从服务器获取产品:

flutter cant get products

主中的我的

.htaccess
文件和图中的公共文件。

.htacces and /public/.htaccess files

我的 laravel 网站(运行良好,我可以从数据库获取产品)

enter image description here

我的

.env
文件(我只裁剪了重要的细节)

enter image description here

服务器中我的Cpanel文件管理器:

file manager

我的

/public/
文件夹文件管理器:

/Public/ folder

有什么解决办法吗?

问题出在服务器而不是 flutter 应用程序,因为我尝试了其他服务器并且它有效。

laravel flutter dart e-commerce
1个回答
0
投票

您应该使用带有查询参数的获取数据,

喜欢这个例子。

final queryParameters = {
'username' : username,
};

final uri = Uri.http('http://example.com','/your sub page',queryParameters);

final response = await http.get(uri,
headers: {
  "Content-Type": "application/application-json",
},);

它对我有用

© www.soinside.com 2019 - 2024. All rights reserved.