onSuccess method

  1. @override
void onSuccess(
  1. VoltronHttpRequest request,
  2. VoltronHttpResponse response,
  3. JSPromise promise
)
override

success callback

Implementation

@override
void onSuccess(
  VoltronHttpRequest request,
  VoltronHttpResponse response,
  JSPromise promise,
) {
  var respMap = VoltronMap();
  respMap.push("statusCode", response.statusCode);
  var rspBody = '';
  try {
    rspBody = json.encode(response.data);
  } catch (e) {
    rspBody = response.data.toString();
  }
  respMap.push("respBody", rspBody);
  respMap.push("statusLine", response.statusMessage);
  respMap.push("respHeaders", response.headerMap.toVoltronMap());
  respMap.push("respBody", rspBody);
  promise.resolve(respMap);
}