You are using a browser that is no longer supported. Please use the latest version of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. For more information please see the System Requirements.
Skip To ContentArcGIS for DevelopersSign In Dashboard

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample shows how retrieve data from a remote server with some basic options.

The first thing you want to do is define the options for your request.

var options = {
  // These properties will be appended to the request URL in the following format:
  // <url>?f=json
  query: {
    f: "json"
  // Determine the format you want to read the response as.
  // Default type is 'json'. Other values are 'xml', 'text', 'blob', 'arraybuffer', 'document'.
  responseType: "json"

The response object will consist of the properties data, requestOptions and url. You can handle the response as needed.

// The URL is the first argument, you can also pass the options as the second argument.
esriRequest(url, options).then(function(response) {
  // In this case, we simply print out the response to the page.
  var responseJSON = JSON.stringify(response, null, 2);
  resultsDiv.innerHTML = responseJSON;

Sample search results