I have the following axios
call in my code. It should return a number from my database
in the column slots
. In the code below, the console log for the response shows the correct number, then I return it to process in another function, however when I try to do math with it, I get an NaN
result!
I've even tried using parseInt
and no luck there as well. Any advice?
function getCurrentSlotsAxios(group_id) {
axios.get('group/' + group_id)
.then( (response) => {
console.log('getCurrentSlotsAxios ' + group_id +': ' + parseInt(response.data.slots)) //shows the correct # in console
return parseInt(response.data.slots) //attempted parseInt in case it was returned as a string for some reason
})
.catch( function(error) {
console.log(error)
}
)
}
Then in another function:
let current_slots = getCurrentSlotsAxios(group_id)
console.log(current_slots + 1) // results in NaN whether I use parseInt or not :(