flutter api curl request code example
Example: 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);
}