app/lib/api/api.dart

52 lines
1.3 KiB
Dart
Raw Normal View History

2022-04-22 22:08:59 +02:00
import 'package:dio/dio.dart';
import 'package:nekoya_flutter/api/config.dart';
Future<dynamic> getProducts() async {
var req = await Dio().get(host + '/getproducts');
var res = req.data;
return res;
2022-04-25 08:48:14 +02:00
}
Future<dynamic> getProduct(id) async {
var req = await Dio().get(host + '/getproduct', queryParameters: {'id': id});
var res = req.data;
return res;
2022-04-25 15:24:26 +02:00
}
Future<dynamic> registerPost(data) async {
2022-04-25 15:24:26 +02:00
Response req = await Dio().post(
(host + '/register'),
data: data,
2022-04-25 15:24:26 +02:00
options: Options(
contentType: Headers.formUrlEncodedContentType,
validateStatus: (status) {
return status! < 500;
},
),
);
return req.statusCode;
}
Future<dynamic> loginPost({email, password}) async {
Response req = await Dio().post(
(host + '/login'),
data: {
'email': email,
'password': password,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
validateStatus: (status) {
return status! < 400;
},
),
);
return req.statusCode;
}
2022-04-27 08:20:01 +02:00
Future<dynamic> getTransactions() async {
String tempKey = 'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp';
var req = await Dio().post(host + '/transaction', queryParameters: {'key': tempKey});
var res = req.data;
return res;
}