[openstreetmap/openstreetmap-website] Get directions using fetch (PR #5642)

Holger Jeromin notifications at github.com
Mon Feb 10 07:48:08 UTC 2025


@HolgerJeromin commented on this pull request.



> @@ -99,22 +99,18 @@
               language: I18n.currentLocale()
             }
           })
-        };
-        return $.ajax({
-          url: OSM.FOSSGIS_VALHALLA_URL,
-          data,
-          dataType: "json",
-          success: function ({ trip }) {
-            if (trip.status === 0) {
-              callback(false, _processDirections(trip.legs));
-            } else {
-              callback(true);
+        });
+        return fetch(OSM.FOSSGIS_VALHALLA_URL + "?" + query)
+          .then(response => response.json())
+          .then(({ trip }) => {
+            if (trip.status !== 0) {

The callback result can not be used.
```ts
            if (trip.status !== 0) {
              return callback(true);
            }
            return callback(false, _processDirections(trip.legs));
```
or
```ts
            if (trip.status !== 0) {
              callback(true);
              return;
            }
            callback(false, _processDirections(trip.legs));
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5642#pullrequestreview-2604912111
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5642/review/2604912111 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250209/c4bc3280/attachment.htm>


More information about the rails-dev mailing list