【发布时间】:2020-05-16 23:37:21
【问题描述】:
我正在使用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');
}
}
知道如何解决这个问题
Problem about Socket exception
更新:
找到解决方案: 如果您在本地运行服务器并使用 Android 模拟器,那么您的服务器端点应该是 10.0.2.2:8000 而不是 localhost:8000,因为 AVD 使用 10.0.2.2 作为主机环回接口的别名(即 localhost
清楚的解释检查这个答案:
SocketException: OS Error: Connection refused, errno = 111 in flutter using django backend
非常感谢大家帮助我!!❤❤❤
【问题讨论】:
-
当您运行此代码时,您的 Strapi 应用程序是否在您的本地主机中运行
-
是的!!!! Strapi 服务器在后台运行
-
如果我访问 localhost:1337/auth/local/register 则显示 {"statusCode":404,"error":"Not Found","message":"Not Found"}
-
看看我已经在这里给出的答案stackoverflow.com/a/62994991/11874673