API service added
This commit is contained in:
parent
69d4c73360
commit
0b38c8e757
1 changed files with 17 additions and 0 deletions
|
|
@ -12,6 +12,23 @@ import 'package:supertokens_flutter/supertokens.dart';
|
|||
class MihUserApis {
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
|
||||
static Future<bool> isUsernameUnique(
|
||||
String username,
|
||||
BuildContext context,
|
||||
) async {
|
||||
var response = await http.get(Uri.parse(
|
||||
"${AppEnviroment.baseApiUrl}/users/validate/username/$username"));
|
||||
if (response.statusCode == 200) {
|
||||
String body = response.body;
|
||||
var jsonBody = jsonDecode(body);
|
||||
|
||||
return jsonBody["available"];
|
||||
} else {
|
||||
throw Exception(
|
||||
"Error: isUsernameUnique status code ${response.statusCode}");
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> deleteAccount(
|
||||
String app_id,
|
||||
BuildContext context,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue