Skip to content

withOptions

Function
withOptions<K, T>(defaultOptionsIRequestOptions, funcT): (funcArgsParameters<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);
Type Parameters
ParameterType
KIRequestOptions
T(argsany[]) => any
Parameters
ParameterTypeNotes
defaultOptionsIRequestOptions

The options to pass into to the func .

funcT

Any function that accepts anything extending IRequestOptions as its last parameter.

Returns 
(funcArgsParameters<T>) => ReturnType<T>

A copy of func with the defaultOptions passed in as defaults.

    function(funcArgsParameters<T>): ReturnType<T>
    Parameters
    ParameterType
    funcArgsParameters<T>
    Returns 
    ReturnType<T>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.