Sag*_*nde 8 mangodb flutter strapi
我使用的是 Strapi.io 开源 Node.js Headless CMS
这是我的注册页面代码
void _registerUser() 异步 {
http.Response response =
await http.post('http://localhost:1337/auth/local/register', body: {
"username": _userName,
"email": _email,
"password": _password,
});
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
// If the call to the server was successful, parse the JSON
return print(responseData);
} else {
// If that call was not successful, throw an error.
throw Exception('Failed to load post');
}
Run Code Online (Sandbox Code Playgroud)
}
知道如何解决这个问题
更新:
找到解决方案:如果您在本地运行服务器并使用 Android 模拟器,那么您的服务器端点应该是 10.0.2.2:8000 而不是 localhost:8000,因为 AVD 使用 10.0.2.2 作为主机环回接口的别名(即) 本地主机
清楚的解释结帐这个答案:
SocketException:操作系统错误:连接被拒绝,errno = 111 in flutter using django backend
非常感谢大家对我的帮助!!!???
Moh*_*eda 12
1 打开 cmd
2ipconfig
在cmd下运行
3 从 cmd 复制 IPv4 地址
4 在 'http://localhost:1337/auth/local/register' 用你的 IPv4 地址替换 'localhost'
5 运行你的应用
对于 MAC 用户
而不是localhost
,把你的MAC IP address
. 移动设备无法识别本地主机。
点击
苹果徽标 > 系统首选项 > 网络
在连接的网络下你可以找到你的wifi ip
之后而不是
http://本地主机:1337
你可以使用你的wifi ip
归档时间: |
|
查看次数: |
18713 次 |
最近记录: |