I work with georeferencing system, I'm doing a search by taxpayer name and in response he returns a batch on the map, he makes a request in the database and if the request is true he redirects to the batch using async / await it works, but I can't use it because in production babel doesn't accept
async buscarGeometria(entidade) {
let entidadeAnterior = entidade;
if (entidade && entidade.id) {
this.LoadingManager.show();
if (entidade && entidade.isPessoa) {
entidade = await this.DataFactory.GET(this.URL.LOTES() + '/' + entidade.val.lotes[0].id);
entidade.URL = this.URL.LOTES();
entidade.box = 'BoxInformacoesCadastrais';
}
this.DataFactory
.GET(entidade.URL + '/geometria/' + entidade.id)
.then(response => {
if (response && response.geom) {
entidadeAnterior.isPessoa ? this.CentralizaMapaBuscasService.centralizaMapa(this.mapa, entidade.centroide)
: this.CentralizaMapaBuscasService.centralizaMapa(this.mapa, entidade.val.centroide);
this.select = this.CentralizaMapaBuscasService.getSelect('Lotes', this.mapa);
this.CentralizaMapaBuscasService.criarFeatureAndSelect(response.geom, this.select)
entidadeAnterior.isPessoa ? this.CentralizaMapaBuscasService.mostraBroadcast(entidade.box, entidade)
: this.CentralizaMapaBuscasService.mostraBroadcast(entidade.box, entidade.val);
}
}).finally(() => this.LoadingManager.hide());
}
}
but I can't use async / await for babel compatibility issue, I made promises but it didn't work
buscarGeometria(entidade) {
let entidadeAnterior = entidade;
if (entidade && entidade.id) {
this.LoadingManager.show();
if (entidade && entidade.isPessoa) {
this.DataFactory.GET(this.URL.LOTES() + '/' + entidade.val.lotes[0].id).then((snap) => {
entidade = snap;
entidade.URL = this.URL.LOTES();
entidade.box = 'BoxInformacoesCadastrais';
});
}
this.DataFactory.GET(entidade.URL + '/geometria/' + entidade.id).then(response => {
if (response && response.geom) {
entidadeAnterior.isPessoa ? this.CentralizaMapaBuscasService.centralizaMapa(this.mapa, entidade.centroide)
: this.CentralizaMapaBuscasService.centralizaMapa(this.mapa, entidade.val.centroide);
this.select = this.CentralizaMapaBuscasService.getSelect('Lotes', this.mapa);
this.CentralizaMapaBuscasService.criarFeatureAndSelect(response.geom, this.select);
entidadeAnterior.isPessoa ? this.CentralizaMapaBuscasService.mostraBroadcast(entidade.box, entidade)
: this.CentralizaMapaBuscasService.mostraBroadcast(entidade.box, entidade.val);
}
}).finally(() => this.LoadingManager.hide());
}
}
I would like to know some other way to do this, thanks