I am currently utilizing vue.js along with axios to retrieve data from an API endpoint.
The specific URL I require is structured like this:
https://base_url.com?f=json&where=&returnGeometry=false&spatialRel=esriSpatialRelIntersects&geometry={"rings":[[[346564.4406999983,6675729.9070999995],[346507.04410000145,6675711.315700002],[346501.2646000013,6675723.884199999],[346495.0234000012,6675737.456500001],[346555.5135000013,6675757.049900003],[346555.91690000147,6675757.180699997],[346555.92969999835,6675757.141800001],[346557.9803000018,6675750.865099996],[346559.90100000054,6675744.985399999],[346560.7393000014,6675742.419500001],[346564.2879999988,6675731.5568],[346564.4406999983,6675729.907099999...
However, when using axios, the parameters get transformed into a different format:
?f=json&where=&returnGeometry=false&spatialRel=esriSpatialRelIntersects
&geometry=%257B%2522rings%2522%253A%255B%255B%255B346564.4406999983%252C6675729.9070999995%255D%252C%255B346507.04410000145%252C6675711.315700002%255D%252C%255B346501.2646000013%252C6675723.884199999%255D%252C%255B346495.0234000012%252C6675737.456500001%255D%252C%255B346555.5135000013%252C6675757.049900003%255D%252C%255B346555.91690000147%252C6675757.180699997%255D%252C%255B346555.92969999835%252C6675757.141800001%255D%252C%255B346557.9803000018%252C6675750.865099996%255D%252C%255B346559.90100000054%252C6675744...
The API endpoint, on the other hand, expects the parameters in this format:
f=json&where=&returnGeometry=false&spatialRel=esriSpatialRelIntersects&geometry=%7B%22rings%22%3A%5B%5B%5B346564.4406999983%2C6675729.9070999995%5D%2C%5B346507.04410000145%2C6675711.315700002%5D%2C%5B346501.2646000013%2C6675723.884199999%5D%2C%5B346495.0234000012%2C6675737.456500001%5D%2C%5B346555.5135000013%2C6675757.049900003%5D%2C%5B346555.91690000147%2C6675757.180699997%5D%2C%5B346555.92969999835%2C6675757.141800001%5D%2C%5B346557.9803000018%2C6675750.865099996%5D%2C%5B346559...
It appears that the encoding for the geometry parameter is incorrect or differs from what the API requires.
Here is the snippet of my code:
return axios
.get(process.env.VUE_APP_WATERINFO_RISK_URL, {
params: {
f: 'json',
where: '',
returnGeometry: false,
spatialRel: 'esriSpatialRelIntersects',
geometry:
{
"rings": [[[346564.4406999983, 6675729.9070999995], [346507.04410000145, 6675711.315700002], [346501.2646000013, 6675723.884199999], [346495.0234000012, 6675737.456500001], [346555.5135000013, 6675757.049900003], [346555.91690000147, 6675757.180699997], [346555.92969999835, 6675757.141800001], [346557.9803000018, 6675750.865099996], [346559.90100000054, 6675744.985399999], [346560.7393000014, 6675742.419500001], [346564.2879999988, 6675731.5568], [346564.4406999983, 6675729.9070999995]]],
"spatialReference": { "wkid": 102100, "latestWkid": 3857 }
}
,
geometryType: 'esriGeometryPolygon',
inSR: '102100',
outFields: '*',
outSR: '102100',
callback: ''
}
})
.then(
response => {
console.log(response);
})
.catch(error => {
console.log(error);
});
What steps should I take to ensure my data/url conforms to the proper format for the endpoint?
Thank you in advance :)