class ApiUtl {
static const String MAIN_API_URL = 'http://localhost/laravel/generalshop/public/api/';
static const String AUTH_REGISTER = MAIN_API_URL + 'auth/register';
static const String AUTH_LOGIN = MAIN_API_URL +'auth/login';
}
Future<List<ProductCategory>> fetchCategories() async {
await checkInternet();
String url = ApiUtl.CATEGORIES
print("enter");
http.Response response = await http.get(url, headers: headers);
switch (response.statusCode) {
case 200:
print(response.statusCode);
List<ProductCategory> categories = [];
var body = jsonDecode(response.body);
for (var item in body['data']) {
categories.add(ProductCategory.fromJson(item));
}
print(categories);