Example
Request
const params = {
'x': '-87.309014',
'y': '30.552461',
'token': '[INSERT-VALID-TOKEN-HERE]',
'projectid': '29043795-D22D-4BA2-B496-689198E0130F'
}
const searchParams = Object.keys(params).map((key) => {
return encodeURIComponent(key) + '=' + encodeURIComponent(params[key])
}).join('&')
const response = await fetch('https://[INSERT-APP-URL-HERE]/query', {
method: 'POST',
headers:{
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: searchParams
}).then(res => res.json())
Response
{
"boundary": {
"query": "Boundary",
"description": "Specify whether point is in client boundary",
"result": "inside"
},
"location": {
"query": "Location",
"description": "Determine what boundary the location falls in",
"result": "Escambia County"
},
"zone": {
"query": "Zone",
"description": "Determine what client zone the location falls in",
"result": "Zone 3"
},
"maintenance": {
"query": "Maintenance",
"description": "Determine nearest eligible or ineligible road",
"result": {
"entity": "Escambia County",
"street": "GREEN HILLS RD",
"distance_ft": 62.06399576725591,
"near_far": "near",
"eligible_entity": true
}
}
}
Generating Token
const getToken = async () => {
// get token before test suite runs
const params = {
username: [USERNAME],
password: [PASSWORD],
referer: 'tests'
}
const searchParams = Object.keys(params).map((key) => {
return encodeURIComponent(key) + '=' + encodeURIComponent(params[key])
}).join('&')
const response = await fetch('https://gis.thompsoncs.net/arcgis/sharing/rest/generateToken?f=json&expiration=20160', {
method: 'POST',
headers:{
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: searchParams
}).then(res => res.json())
token = response.token
return Promise.resolve()
}