简体   繁体   中英

How to get title/item from response.body (HTTP - JSON)

I want to pull certain headers and items under the headers as string data from the JSON.

Map dataSignUpEmployeer = {
  'corporationName': employeer.getCorporationName(),
  'webSiteName': employeer.getWebSiteName(),
  'email': employeer.getEmail(),
  'password': employeer.getPassword(),
};

String bodySignUpEmployeer = json.encode(dataSignUpEmployeer);

postDataSignUpEmployeer() async {
  final response = await http.post(
    Uri.parse(urlSignUp),
    headers: {"Content-Type": "application/json"},
    body: bodySignUpEmployeer,
  );
  return response.body;
}

response.body return JSON

Eesponse.body's return: 在此处输入图像描述 Please help me in any way.

your code is working as well i see so i think you wrong in a part of your code for get the success: true from your response body so maybe you need to authorize your user in header of post method with Token . to get back success true and get all of each user data. any way we should see your api url.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM