Esri / arcgis-rest-js

compact, modular JavaScript wrappers for the ArcGIS REST API
https://developers.arcgis.com/arcgis-rest-js/
Apache License 2.0
353 stars 119 forks source link

New geocode URL requires token #803

Closed yankuanz closed 3 years ago

yankuanz commented 3 years ago

In our app we recently encountered a regression when using suggest and geocode (we used to make the these requests without passing in any authentication) because of the change of the default geocode URL https://github.com/Esri/arcgis-rest-js/commit/613837ddaa0638f826aa75d11c00ee1007cb6e72:

image

Would assume everthing should just work before and after the URL update. Is this expected?


So once we did pass in this time, we got another error

image

Note that we are making the requests from devext tier. Is this also expected? What would be best practice in here?

Thanks!

vicb commented 7 months ago

Hum I am getting this error and can not find anything in the docs!

vicb commented 7 months ago

It seems like you should use setDefaultRequestOptions and pass the token value in the params

yankuanz commented 7 months ago

It seems like you should use setDefaultRequestOptions and pass the token value in the params

Thanks @vicb . Will give it a shot!

vicb commented 7 months ago

Here is what I use successfuly:

import { geocode } from '@esri/arcgis-rest-geocoding';
import { setDefaultRequestOptions } from '@esri/arcgis-rest-request';

setDefaultRequestOptions({ params: { token: "...your API key..." } });
const { candidates } = await geocode(address);