import TomtomInternationalWebSdkServices from "https://cdn.skypack.dev/@tomtom-international/web-sdk-services@6.19.0";

function calculateRoute(traffic){
  const routeOptions =  {
    "key": "API_KEY",
    "traffic":traffic,
    "locations": [
      {
        "lat": 51.73401,
        "lon": -0.48866,
      },
      {
        "lat": 50.70005,
        "lon": -3.51274,
      },
    ],
  }
  TomtomInternationalWebSdkServices.services.calculateRoute(routeOptions)
      .then((response) => {
          console.log("traffic: ", traffic)
          console.log(JSON.stringify(response));
      })
      .catch((error) => {
          console.log("traffic: ", traffic)
          console.log(error)
      })
}

calculateRoute(false)
calculateRoute(true)
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.