-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapiCalls.dart
43 lines (42 loc) · 1.37 KB
/
apiCalls.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//This file will contain all the rest api integrations code for create/post/patch/delete
import 'dart:convert';
import 'package:dash_admin_dashboard/Dashboard/MenuItems/feature.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
class NetworkHandler {
String baseurl = "http://dev-doas.codsgn.in/v1/";
Future<http.Response> post(String url, Map<String, String> body) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String token = prefs.getString("token");
url = formatter(url);
print(url);
var response = await http.post(
Uri.parse(url),
headers: {
"Content-type": "application/json",
'Accept': 'application/json',
'Authorization': 'Bearer $token',
},
body: json.encode(body),
);
print(response.body);
return response;
}
Future<http.Response> post1(String url, var body) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String token = prefs.getString("token");
url = formatter(url);
print(url);
var response = await http.post(
Uri.parse(url),
headers: {
"Content-type": "application/json",
'Accept': 'application/json',
'Authorization': 'Bearer $token',
},
body: json.encode(body),
);
print(response.body);
return response;
}
}