correction post user

pull/1/head
Enzo 2 years ago
parent a0ed987c83
commit 8e0bef3f70

@ -101,22 +101,10 @@ class RequestApi extends IDataStrategy {
@override @override
Future<Tuple2<bool, String>> postUser( Future<Tuple2<bool, String>> postUser(
String email, String hash, String username) async { String email, String hash, String username) async {
print(email); var body = {"email": email, "hash": hash, "username": username};
print(hash); var header = {"Content-Type": "application/json"};
print(username); final response = await http.post(Uri.parse('$urlApi/user'),
headers: header, body: jsonEncode(body));
print(<String, String>{
"\"email\"": "\"$email\"",
"\"hash\"": "\"$hash\"",
"\"username\"": "\"$username\""
});
final response =
await http.post(Uri.parse('$urlApi/user'), body: <String, String>{
"\"email\"": "\"$email\"",
"\"hash\"": "\"$hash\"",
"\"username\"": "\"$username\""
});
if (response.statusCode == 200) { if (response.statusCode == 200) {
Map<String, dynamic> json = jsonDecode(response.body); Map<String, dynamic> json = jsonDecode(response.body);
@ -167,7 +155,10 @@ class RequestApi extends IDataStrategy {
Future<Tuple2> modifAttribut( Future<Tuple2> modifAttribut(
String token, String nameAttribut, String newValue) async { String token, String nameAttribut, String newValue) async {
final response = await http.put(Uri.parse('$urlApi/user/$nameAttribut'), final response = await http.put(Uri.parse('$urlApi/user/$nameAttribut'),
headers: <String, String>{'Authorization': token}, headers: <String, String>{
'Authorization': token,
"Content-Type": "application/json"
},
body: jsonEncode(<String, String>{nameAttribut: newValue})); body: jsonEncode(<String, String>{nameAttribut: newValue}));
if (response.statusCode == 200) { if (response.statusCode == 200) {

Loading…
Cancel
Save