initialisePostRequest static method

dynamic initialisePostRequest({
  1. required Map<String, dynamic> data,
  2. required String url,
  3. dynamic token,
  4. dynamic apiKey,
})

Implementation

static initialisePostRequest(
    {required Map<String, dynamic> data,
    required String url,
    token,
    apiKey}) async {
  try {
    var response = await _makePostRequest(
        apiUrl: url, data: data, token: token, apiKey: apiKey);
    var body = jsonDecode(response.body);
    if (_isRequestSuccessful(response.statusCode)) {
      return body;
    } else {
      return _handleError(response);
    }
  } catch (e) {
    print(e.toString());
    return e.toString();
  }
}