withOptions(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.
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
Parameter | Type | Notes |
---|
defaultOptions
| IRequestOptions | The options to pass into to the func . |
func
| T | Any function that accepts anything extending IRequestOptions as its last parameter. |
(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.
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
Parameter | Type |
---|
funcArgs
| Parameters<T> |
ReturnType<T>
A copy of func
with the defaultOptions
passed in as defaults.