This is my first react app and I am trying to fetch API using axios.
The URL can be changed based on a value.
My code is
fetchURL(page,checked) {
if(checked)
{
const apiUrl = 'firstApiURL'
}
else {
const apiUrl = 'secondApiURL';
}
axios.get(apiUrl)......
}
It says apiUrl is undefined.
I thought it would be easy to change the API url based on another variable.
Any help is highly appreciated.