Skip to content

Commit ff9dc23

Browse files
committed
fix promise resolution
1 parent d229606 commit ff9dc23

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

lib/index.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,16 +735,35 @@ MapboxGeocoder.prototype = {
735735

736736
const requestType = this._requestType(this.options, searchInput);
737737

738-
let config;
738+
var config;
739739
// setup request parameters config and pre-validate values
740740
try {
741741
config = this._setupConfig(requestType, searchInput);
742742
} catch (err) {
743-
this._hideLoadingIcon();
744-
this._hideAttribution();
745-
this._typeahead.selected = null;
746-
this._renderCustomError(err.message);
747-
return Promise.resolve();
743+
const request = new Promise(function (resolve) {
744+
resolve();
745+
});
746+
request.then(function() {
747+
return {
748+
type: 'FeatureCollection',
749+
features: [],
750+
config
751+
}
752+
}.bind(this))
753+
.then(function(){
754+
this._hideLoadingIcon();
755+
this._hideAttribution();
756+
this._typeahead.selected = null;
757+
this._renderCustomError(err.message);
758+
this._eventEmitter.emit('results', {
759+
type: 'FeatureCollection',
760+
features: [],
761+
config
762+
});
763+
this._eventEmitter.emit('error', { error: err });
764+
765+
}.bind(this))
766+
return request
748767
}
749768

750769
var request;

0 commit comments

Comments
 (0)