Skip to content

Instantly share code, notes, and snippets.

@asizer
Created July 11, 2014 22:25
Show Gist options
  • Save asizer/56f82d11be0e1c223599 to your computer and use it in GitHub Desktop.
Save asizer/56f82d11be0e1c223599 to your computer and use it in GitHub Desktop.
Make dojo xhrRequest work with secured service
/* all this is around line 334 of SQLQuery/Widget.js */
// option 1 is to query the rest endpoint for unique values.
// option 2 is to store featureSet clientside (1000 limit)
var tokenRequest = esri.id.findCredential(this.activeInfo.fLayerUrl); // THIS IS NEW!
if (!this.activeInfo.featureSet) {
dojoXhr(this.activeInfo.fLayerUrl + '/query', {
query: {
where: '1=1',
outFields: fieldInfo.name,
returnDistinctValues: true,
f: 'json',
returnGeometry: false, // don't forget to add a comma here...
token: tokenRequest ? tokenRequest.token : null // THIS IS ALSO NEW!
},
headers: {
'X-Requested-With': null
},
handleAs: "json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment