使用http post方法抖动时出错

时间:2019-07-29 06:51:43

标签: http flutter http-headers

在将注册api轻而易举地发布时,我得到的成功消息为false,首先,我使用客户端url并获得令牌,然后将令牌传递给标头og寄存器api。

Future<Register> fetchPost0() async {
  print('feg');
  SharedPreferences prefs = await SharedPreferences.getInstance();
  //String token = prefs.getString('token');

  String receivedToken = await _getMobileToken("BearerToken");

  receivedToken = "Bearer "+ receivedToken;

  print(receivedToken + "======================");


  Map  formData = {
    "firstname": "Dsemo",
    "lastname": "Usesr",
    "email": "sdfdsfsdf.asdf@vipmasdfil.hu",
    "password": "password",
    "confirm": "password",
    "address_1": "Demo",
    "country_id": "81",
    "postcode": "3333",
    "zone_id": "1256",
    "tax_id": "1",
    "customer_group_id": "1",
    "agree": "1"

  };


  final response = await http.post(
    'http://your api/register/register', body: json.encode(formData)
    ,
    headers: {
      'Authorization': receivedToken
      },
  );
  print(response.body);
  var   responseJson = json.decode(response.body);
  print("Result: ${response.body}"); 
  return Register.fromJson(responseJson);
}

现在我正在编辑能正常工作的代码。

0 个答案:

没有答案