init
This commit is contained in:
22
lib/https/auth_api.dart
Normal file
22
lib/https/auth_api.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as Http;
|
||||
|
||||
class HttpApi {
|
||||
final String BaseApi = 'http://api.gl.shangkelian.cn/api/';
|
||||
|
||||
/// post
|
||||
ApiPost(String api, {Map? body}) async {
|
||||
String apiUrl = BaseApi + api;
|
||||
var url = Uri.parse(apiUrl);
|
||||
var response = await Http.post(url, body: body);
|
||||
int newCode = response.statusCode;
|
||||
Map data = jsonDecode(response.body);
|
||||
|
||||
if (newCode == 200) {
|
||||
print('请求成功返回值$data');
|
||||
return data;
|
||||
}
|
||||
// print(apiUrl);
|
||||
// print('可选参数${body}');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user