我正在使用 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');
}
}
知道如何解决这个问题
关于Socket异常的问题 https://i.stack.imgur.com/8NgyC.jpg
update:
找到了解决方案:
如果您在本地运行服务器并使用 Android 模拟器,那么您的服务器端点应该是 10.0.2.2:8000 而不是 localhost:8000,因为 AVD 使用 10.0.2.2 作为主机环回接口的别名(即 localhost)
明确的解释查看这个答案:
SocketException:操作系统错误:连接被拒绝,errno = 111 在使用 django 后端的 flutter 中 https://stackoverflow.com/questions/55785581/socketexception-os-error-connection-refused-errno-111-in-flutter-using-djan
非常感谢大家帮助我!!❤❤❤
1 打开cmd
2 run ipconfig
at cmd
3 从cmd复制IPv4地址
4 在 'http://localhost:1337/auth/local/register' 将 'localhost' 替换为您的 IPv4 地址
5 运行您的应用程序
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)