I have a global variable that fetches an API URL and I want to add it to my action.js file.
mainUrl.js
const MAIN_URL="www.testexamplebeta.com"
action.js
import {MAIN_URL} from '../mainUrl'
export function fetchPets() {
return function(dispatch) {
console.log("THE URL IS", MAIN_URL)
axios.get(`${MAIN_URL}/tests`)
.then(response => {
dispatch({
type: FETCH_TESTS,
payload: response
});
})
.catch(() => {
console.log("Can't fetch the test examples");
});
}
}
When I console.log the MAIN_URL I get undefined.