I have the following code inside a render function in react
let newCat
this.props.client.query({
query: queryCategoriesForCategoryListPage,
name: 'fetchCategories',
variables: {
incubatorId: this.props.getCurrentUser.currentUser.incubator._id
}
}).then((cat)=>{
console.log("cat resolved is: ",cat)
if(cat.data && cat.data.categories)
newCat = cat.data.categories
})
console.log("newCat is: ",newCat)
the cat variable inside the .then seems to be behaving correctly but newCat seems to be undefined , how can i fix that?