API: client-async
Source:
http/client-async.ts
Defines a single HTTP header, used for both request and response.
Usage
import { client, clientAsync } from "sdk/http";
let clientAsyncInstance = clientAsync.getInstance();
let api = 'https://services.odata.org/V4/Northwind/Northwind.svc/';
let northWindResponse = client.get(api, {
params: [{
name: "$format",
value: "json"
}]
});
let northWindEntities = JSON.parse(northWindResponse.text);
for (let i = 0; i < northWindEntities.value.length; i++) {
clientAsyncInstance.getAsync(api + northWindEntities.value[i].url, {
success: function (response) {
let entity = JSON.parse(response.text);
console.error(entity["@odata.context"] + " : " + entity.value.length);
}
});
}
clientAsyncInstance.execute();Classes
HttpAsyncClient
The asynchronous HTTP client class. All request methods return immediately
and execute callbacks upon completion.
Methods
getAsync
getAsync (url:string, config:HttpClientAsyncConfig, options?:HttpClientRequestOptions):voidExecutes an asynchronous HTTP GET request.
@param url The target URL.
@param config The callback configuration object.
@param options Request configuration options (e.g., headers, body, params).
postAsync
postAsync (url:string, config:HttpClientAsyncConfig, options?:HttpClientRequestOptions):voidExecutes an asynchronous HTTP POST request.
@param url The target URL.
@param config The callback configuration object.
@param options Request configuration options.
putAsync
putAsync (url:string, config:HttpClientAsyncConfig, options?:HttpClientRequestOptions):voidExecutes an asynchronous HTTP PUT request.
@param url The target URL.
@param config The callback configuration object.
@param options Request configuration options.
patchAsync
patchAsync (url:string, config:HttpClientAsyncConfig, options?:HttpClientRequestOptions):voidExecutes an asynchronous HTTP PATCH request.
@param url The target URL.
@param config The callback configuration object.
@param options Request configuration options.
deleteAsync
deleteAsync (url:string, config:HttpClientAsyncConfig, options?:HttpClientRequestOptions):voidExecutes an asynchronous HTTP DELETE request.
@param url The target URL.
@param config The callback configuration object.
@param options Request configuration options.
headAsync
headAsync (url:string, config:HttpClientAsyncConfig, options?:HttpClientRequestOptions):voidExecutes an asynchronous HTTP HEAD request.
@param url The target URL.
@param config The callback configuration object.
@param options Request configuration options.
traceAsync
traceAsync (url:string, config:HttpClientAsyncConfig, options?:HttpClientRequestOptions):voidExecutes an asynchronous HTTP TRACE request.
@param url The target URL.
@param config The callback configuration object.
@param options Request configuration options.
execute
execute ():voidInitiates the execution of queued asynchronous requests (depending on the underlying Java client's threading model).