RequestTask.abort

Requires:
BaseKit≥2.0.1
Platforms:
iOSAndroid

Method signature
RequestTask.abort(params: )

Description

Abort request task

Parameters

PropertyTypeRequiredDescription
complete() => voidNoCompletion callback (executed on both success and failure)
success() => voidNoCallback on successful API call
fail(params: Object) => voidNoFailure callback
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { request } from '@ray-js/ray'

// Abort a request task. ty.request returns a RequestTask; call task.abort to abort the request, and abort returns the result via the success callback.
// Note: abort is called after the request result returns to demonstrate how to call abort and a successful callback.
let task;
task = request({
  url: "https://httpbin.org/get",
  method: "GET",
  success: data => {
    console.log(data);
    task.abort({
      success: () => {
        console.log("abort success");
      },
      fail: error => {
        console.error(error);
      },
    });
  },
  fail: error => {
    console.error(error);
  },
});