I'm trying to call a setState function inside of a _.map loop, but the loop lost the property 'this', and I can't use setState on this because this=undefined
cargaDinamica(){
_.map(this.state.redis, function(cache){
obj.url = 'http://localhost:7000/viewlogredis';
ServiceOS(obj)
.then(retorno => {
console.log("aaaa", this);
view = retorno;
this.setState({log : view});
})
.catch(err => {throw new Error(err)});
obj = {url : 'http://localhost:7000' + cache.WebService,
IPRedis: cache.IPDBMaster,
WebService: cache.WebService,
log : log};
console.log("CARGA: ", obj);
ServiceOS(obj)
.then(function(carga) {
console.log('CHEGOU AQUI');
console.log("OK");
})
.catch(err => {throw new Error(err)});
});
},
this is my react function /\