I have set the state of a array as [] empty, in componentDidMount i am getting the API Response.. now i want to set the state of the empty array with the new array of json response how can i do this?
constructor(props)
{
super(props)
this.state = {
categoryList : []
}
}
componentDidMount()
{
axios.get('http:xxxxxxxxxxxxxxxxxxxxxxx')
.then(res =>
{
this.setState = {
categoryList : res.data.body.category_list(json path)
}
})
.catch(function(error) {
console.log('Error on Authentication' + error);
})
}