ogcApiRequest
Wrapper over fetch for performing common operations when executing a request to an OGC API, such as:
- Creating the query string
- URL encoding query string values
- Appending the ?target query param if needed
- Checking whether the response is ok
- Returning the .json() of the response body
Note: the ?target query param is only appended if the target site (options.site) is different from the the site that will have its OGC API hit (url). This allows us to use the environment-level OGC API's url while actually targeting a specific Hub Site's catalog. It's a powerful capability that significantly eases local development.
Example: https://hubqa.arcgis.com/api/search/v1?target="my-actual-hub.hub.arcgis.com"
We omit the ?target query when the site and url are the same because it would be redundant.
Bad example: https://hubqa.arcgis.com/api/search/v1?target="hubqa.arcgis.com" Good example: https://hubqa.arcgis.com/api/search/v1
Parameters
Returns
the JSON response from the endpoint
Function defined in common/src/search/_internal/hubSearchItemsHelpers/ogcApiRequest.ts:30