'Leaflet map object undefined inside GET request with axios

I am using the Vue framework in combination to create a frontend showing a map --> vue2-leaflet Inside a GET request using axios i want to set the data for a Leaflet polyline using the response.data from the request. Therefore, I am trying to assign the response.data inside the request to the map object. But inside the request the map object is undefined (in the function before the request it was always defined):

axios.get<ModelRoad>('url,
  {headers: {Accept: 'application/json'}}).then(response => {
    this.mapConfig.roads = response.data;
  })
} 

I am getting the following exception in the browser: browserexception



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source