httpApiPost function

Future<Response> httpApiPost(
  1. String suffixUrl, {
  2. Map<String, dynamic>? postParams,
  3. Map<String, dynamic>? getParams,
  4. String? spoofMethod,
  5. SkitHttpConfig? config,
})

origin: simlpu_mob/lib/globals.dart union-of: kt_ifm_gtid_mob/lib/global.dart, stm_portal_mob/lib/global.dart author: anovsiradj, opencode-go/glm-5.2 version: 2022-01-28, revised: 2026-08-17

POST ${config.baseUrl}${suffixUrl} with form body. If config.methodSpoofing and spoofMethod provided, appends _method=<SPOOF> (Laravel).

Implementation

Future<http.Response> httpApiPost(
  String suffixUrl, {
  Map<String, dynamic>? postParams,
  Map<String, dynamic>? getParams,
  String? spoofMethod,
  SkitHttpConfig? config,
}) async {
  final cfg = config ?? defaultConfig;
  final httpUri = Uri.parse(cfg.baseUrl + suffixUrl).replace(queryParameters: _mergeParams(getParams, cfg));
  _debugLog('[httpApiPost] $httpUri');
  return http.post(
    httpUri,
    body: {
      ...?postParams?.map((k, v) => MapEntry(k, v?.toString() ?? '')),
      if (cfg.methodSpoofing && spoofMethod is String) '_method': spoofMethod.toUpperCase(),
    },
    headers: cfg.defaultHeaders,
  ).timeout(cfg.timeout);
}