How to dispatch action from .then() function in component method?


Hello again.
When i async call (from leaflet-geosearch leaflet plugin) it needs to save result in vuex store.

addMarker(e) {
     const provider = new OpenStreetMapProvider(){query:[,e.latlng.lng]}).then(function(result){
      var OrderRoute = {frompoint: [,e.latlng.lng],fromlabel: result[0].label};
      }).catch(error => {

This code returns error
TypeError: “this is undefined” addMarker webpack-internal:///20:99:11

Action SET_ORDER_ROUTE works good out of ‘’ block. Even console.log(OrderRoute) shows truly result of geosearching request.
How can i dispatch action with result of async call?


Uwe an arrow function instead of a normal one for the callback in then()


Thanks again, all works!