@dataforsyningen/saul 3.3.3 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/modules/api.js +10 -3
  2. package/package.json +1 -1
package/modules/api.js CHANGED
@@ -160,18 +160,25 @@ function post(url, requestbody, token) {
160
160
  */
161
161
  function getDHM(query, auth) {
162
162
  const auth_params = `&username=${auth.API_DHM_TOKENA}&password=${auth.API_DHM_TOKENB}`
163
- return get(encodeURI(auth.API_DHM_BASEURL + query + auth_params))
163
+ return get(encodeURI(auth.API_DHM_BASEURL + query + auth_params), {cache: 'force-cache'})
164
164
  .then((data) => data)
165
165
  }
166
166
 
167
167
  /**
168
168
  * API method to GET data from STAC API
169
- * @param {string} query - STAC API query.
169
+ * @param {string} query - STAC API query string. May include endpoint path information.
170
170
  * @param {{API_STAC_BASEURL: string, API_STAC_TOKEN: string}} auth - API autentication data. See ../config.js.example for reference.
171
171
  * @returns {object} Response data
172
172
  */
173
173
  function getSTAC(query, auth) {
174
- return get(auth.API_STAC_BASEURL + query + '&token=' + auth.API_STAC_TOKEN)
174
+ let requestUrl = `${auth.API_STAC_BASEURL}${query}`
175
+ const queryStr = query.split('?')[1]
176
+ if (queryStr) {
177
+ requestUrl += `&token=${auth.API_STAC_TOKEN}`
178
+ } else {
179
+ requestUrl += `?token=${auth.API_STAC_TOKEN}`
180
+ }
181
+ return get(requestUrl)
175
182
  .then((data) => data)
176
183
  }
177
184
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataforsyningen/saul",
3
- "version": "3.3.3",
3
+ "version": "3.4.0",
4
4
  "description": "This is a collection of stand-alone methods for photogrammetry calculations and API interactions for 'Danske Skråfotos'.",
5
5
  "main": "index.js",
6
6
  "type": "module",