withOptions
FunctionwithOptions(defaultOptions: IRequestOptions, func: T): (funcArgs: Parameters<T>) => ReturnType<T>
Allows you to wrap individual methods with a default set of request options. This is useful to avoid setting the same option more then once and allows for interacting and setting defaults in a functional manner.
import { withOptions } from "@esri/arcgis-rest-request";
import { queryFeatures } from '@esri/arcgis-rest-feature-service';
const queryTrails = withOptions({
url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0/"}, queryFeatures);
queryTrails({
where: "ELEV_FT > 1000"
}).then(result);
const queryTrailsAsUser = withOptions({
authentication: ArcGISIdentityManager
}, queryTrails);
queryTrailsAsUser({
where: "TRL_NAME LIKE '%backbone%'"
}).then(result);
Parameters
Parameter | Type | Notes |
---|---|---|
default | IRequestOptions | The options to pass into to the |
func | T | Any function that accepts anything extending |
Returns
(funcArgs: Parameters<T>) => ReturnType<T>
A copy of func
with the defaultOptions
passed in as defaults.
function(funcArgs: Parameters<T>): ReturnType<T>
Allows you to wrap individual methods with a default set of request options. This is useful to avoid setting the same option more then once and allows for interacting and setting defaults in a functional manner.
import { withOptions } from "@esri/arcgis-rest-request";
import { queryFeatures } from '@esri/arcgis-rest-feature-service';
const queryTrails = withOptions({
url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0/"}, queryFeatures);
queryTrails({
where: "ELEV_FT > 1000"
}).then(result);
const queryTrailsAsUser = withOptions({
authentication: ArcGISIdentityManager
}, queryTrails);
queryTrailsAsUser({
where: "TRL_NAME LIKE '%backbone%'"
}).then(result);
Parameters
Parameter | Type |
---|---|
func | Parameters<T> |
Returns
ReturnType<T>
A copy of func
with the defaultOptions
passed in as defaults.