post static method

dynamic post(
  1. String path,
  2. Object item
)

Implementation

static post(String path, Object item) async {
  final config = CConfig();

  try {
    var result = await http.post(Uri.parse('${config.serverUrl}$path'),
        headers: {
          'Content-Type': 'application/json',
          'Authorization': 'Bearer ${config.token}'
        },
        body: jsonEncode(item));
    if (result.statusCode == 200) {
      return json.decode(utf8.decode(result.bodyBytes));
    }
  } catch (e) {
    if (kDebugMode) {
      print(e);
    }
  }

  return null;
}