withOptions

withOptions

Function
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.

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.

    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.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close