callApi static method

Future<Response> callApi(
  1. String route,
  2. dynamic data, {
  3. String token = '',
})

Implementation

static Future<http.Response> callApi(String route,  data, {String token = ''}) async {
	Map<String, String> headers = {};
	headers['Content-Type'] = 'application/json';
	if(token.isNotEmpty){
		headers['Authorization'] = 'Bearer $token';
	}

	return http.post(
			Uri.parse('$apiUrl$route'),
			headers: headers,
			body: data,
	);
}