import 'dart:async'; import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:openmediacentermobile/api/token.dart'; import 'package:openmediacentermobile/log/log.dart'; class API { static Future query( String apinode, String action, Object payload) async { final Completer cmpl = Completer(); final t = await Token.getInstance().getToken(); Log.d(t); if (t != null) { final resp = await http.post( Uri.parse(t.domain + '/api/$apinode/$action'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'Token': t.token }, body: jsonEncode(payload), ); cmpl.complete(resp.body); } else { cmpl.complete(""); } return cmpl.future; } }