0
API URL을 가져오고 action.js 파일에 추가하려는 전역 변수가 있습니다.Javascript/React에서 다른 파일의 전역 문자열 호출
mainUrl.js 내가 정의되지 않은 얻을 MAIN_URL을 CONSOLE.LOG
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");
});
}
}
action.js
const MAIN_URL="www.testexamplebeta.com"
.
오! – lost9123193