Answers for "curl with flutter"

0

curl with flutter

Future<Map<String, dynamic>> postRequest(String nick, String password) async {
  // todo - fix baseUrl
  var url = '{{baseURL}}/api/auth/login';
  var body = json.encode({
    'nick': nick,
    'password': password,
  });

  print('Body: $body');

  var response = await http.post(
    url,
    headers: {
      'accept': 'application/json',
      'Content-Type': 'application/json-patch+json',
    },
    body: body,
  );

  // todo - handle non-200 status code, etc

  return json.decode(response.body);
}
Posted by: Guest on February-27-2021

Browse Popular Code Answers by Language