A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html below:

request | API Reference | ArcGIS Maps SDK for JavaScript 4.33

ESM: import esriRequest from "@arcgis/core/request.js";

CDN: const esriRequest = await $arcgis.import("@arcgis/core/request.js");

Function: @arcgis/core/request

Since: ArcGIS Maps SDK for JavaScript 4.0

Retrieves data from a remote server or uploads a file.

Method Overview Name Return Type Summary Function request() Promise<RequestResponse>

Retrieves data from a remote server or uploads a file from a user's computer.

request Method Details

Retrieves data from a remote server or uploads a file from a user's computer. If the request returns an Error, the error object will include the details specified in EsriErrorDetails.

Returns

Type Definitions
EsriErrorDetails Type Definition EsriErrorDetails

The specification of the details object returned in an Error object.

Properties

A function to retrieve headers sent from the server.

A function for retrieving all headers sent from the server.

The status code of the http response.

The error message code.

Additional error message(s).

The raw error object if the server returned a JSON error, or the response text otherwise.

The options used in the http request.

Indicates if the request required https.

The error message subcode.

The URL of the request that returned an error message.

RequestOptions Type Definition RequestOptions

An object with the following properties that describe the request.

Properties
authMode String optional

Default Value:auto

Indicates if and how requests to ArcGIS Services are authenticated. Only applicable when esriConfig.request.useIdentity = true.

Known Value Description auto The user will be signed in when a secure resource is requested. anonymous An error will be returned when a secure resource is requested. immediate The user will be signed in before the resource is requested. no-prompt Checks for whether the user is already signed in. If so, no additional prompts display for sign-in.

Note: This is not supported when used in a custom worker that is not using the workers framework.

Possible Values:"auto"|"anonymous"|"immediate"|"no-prompt"

body FormData|HTMLFormElement|String|null|undefined optional

If uploading a file, specify the form data or element used to submit the file here. If specified, the parameters of the query will be added to the URL.

cacheBust Boolean optional

Default Value:false

If true, the browser will send a request to the server instead of using the browser's local cache. If false, the browser's default cache handling will be used.

headers Object optional

Headers to use for the request. This is an object whose property names are header names.

method String optional

Default Value:auto

Indicates if the request should be made using the HTTP DELETE, HEAD, POST, or PUT method. By default, HTTP POST will be used for auto if the request size is longer than the maxUrlLength property set in config.request.

Possible Values:"auto"|"delete"|"head"|"post"|"put"

query Object|URLSearchParams optional

Default Value:null

Query parameters for the request. The query parameters will be added to the URL if a GET request is used, or if the body property is set. If the body property is not set, the query parameters will be added to the request body when a DELETE, POST, or PUT request is used.

responseType String optional

Default Value:json

Response format. For details on the specific types, see: json, text, array-buffer, blob, image, native, native-request-init, document, and xml

Possible Values:"json"|"text"|"array-buffer"|"blob"|"image"|"native"|"native-request-init"|"document"|"xml"

signal AbortSignal|null|undefined optional

AbortSignal allows for cancelable requests. If canceled, the promise will be rejected with an error named AbortError. See also AbortController.

Example:

const controller = new AbortController();
const signal = controller.signal;

esriRequest(url, { signal })
  .then((response) => {
    // The request went OK
  })
  .catch((err) => {
    if (err.name === 'AbortError') {
      console.log('Request aborted');
    } else {
      console.error('Error encountered', err);
    }
  });

// Abort requests that are aware of the controller's signal
controller.abort();
timeout Number optional

Default Value:62000

Indicates the amount of time in milliseconds to wait for a response from the server. Set to 0 to wait for the response indefinitely.

useProxy Boolean optional

Default Value:false

Indicates the request should use the proxy. By default, this is determined automatically based on the domain of the request URL.

withCredentials Boolean optional

Default Value:false

Indicates if cross-site Access-Control requests should use credentials. It is also possible to push the domain to the config trustedServers if an application requires credentials. For additional information on withCredentials, please refer to this documentation.

RequestResponse Type Definition RequestResponse

Returns a promise that resolves to an object with the following specification. If the request returns an Error, the error object will include the details specified in EsriErrorDetails.

Example

// request GeoJson data from USGS remote server
let url = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson";

esriRequest(url, {
  responseType: "json"
}).then((response) => {
  // The requested data
  let geoJson = response.data;
});

A function to retrieve all headers sent from the server. CORS only allows a few response headers to be read by default, see: Access-Control-Expose-Headers.

Returns

Type Description String[][] | null | undefined An array of all headers returned from the server. Each header is an array containing the header name and its corresponding value.

Example

esriRequest(url, options)
  .then((response) => {
    console.log("All request headers: ", response.getAllHeaders());
  });

A function to retrieve headers sent from the server. CORS only allows a few response headers to be read by default, see: Access-Control-Expose-Headers.

Returns

Example

esriRequest(url, options)
  .then((response) => {
    // prints the content type of the request: 'application/json'
    console.log("header: ", response.getHeader('Content-Type'));
  });

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4