- await fetch(url)
- .then(response => response.text())
- .then(html => {
- html = html.replace('Nominatim_API_Endpoint', get_config_value('Nominatim_API_Endpoint'));
- dom_element.innerHTML = html;
- fetch_content_cache[url] = html;
- });
+ try {
+ await fetch(url)
+ .then(response => response.text())
+ .then(html => {
+ html = html.replace('Nominatim_API_Endpoint', generate_nominatim_endpoint_url());
+ dom_element.innerHTML = html;
+ fetch_content_cache[url] = html;
+ });
+ } catch (error) {
+ dom_element.innerHTML = `Error fetching content from ${url} (${error})`;
+ }
+}
+
+function generate_nominatim_endpoint_url(endpoint_name) {
+ var conf_endpoint = Nominatim_Config.Nominatim_API_Endpoint;
+
+ if (typeof conf_endpoint === 'function') {
+ return conf_endpoint(endpoint_name);
+ }
+
+ if (!endpoint_name) return conf_endpoint;
+
+ return conf_endpoint + endpoint_name + '.php';