@dataforsyningen/saul 3.3.2 → 3.3.4
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.
- package/modules/api.js +9 -2
- package/package.json +1 -1
package/modules/api.js
CHANGED
|
@@ -166,12 +166,19 @@ function getDHM(query, auth) {
|
|
|
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
|
-
|
|
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