withOptions

withOptions

withOptions(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);
Parameters
ParameterTypeNotes
defaultOptions
IRequestOptions

The options to pass into to the func.

func
T

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>

    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);
    
    Parameters
    ParameterType
    funcArgs
    Parameters<T>
    Returns 
    ReturnType<T>

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

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