登录移动应用程序rest api [已关闭]

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

我一直在尝试在我的 dart 中实现 REST API,但是出现了这个错误:

I/flutter (27517):失败,状态代码:400

当我尝试使用 Postman 时,效果很好

Future<void> login() async { 
    var url = Uri.parse("http://192.168.0.111:3000/auth/signin");
    var response = await http.post ( url, body: {
        'email': _emailController.text,
        'password': _passwordController.text,
    });
    if (response.statusCode == 200) { 
        var data = jsonDecode(response.body.toString()); 
        print(data['token']); 
        print('Login Successfully');
    }
    else{ 
        print('Failed with status code: ${response.statusCode}');
    }
}
node.js flutter authentication
1个回答
-1
投票

您尚未添加标题。请添加所需的标头并尝试。如果网址正确,它应该可以工作。

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