update
This commit is contained in:
53
lib/services/auth_service.dart
Normal file
53
lib/services/auth_service.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
|
||||
class AuthService{
|
||||
|
||||
static Future<Map<String, dynamic>> login(String email, String password) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String url = 'http://localhost:8100/api/login/';
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'email': email,
|
||||
'password': password
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
static Future<Map<String, dynamic>> register(String email, String password) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String url = 'http://localhost:8100/api/register/';
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'email': email,
|
||||
'password': password
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user