I have a code snippet where I want to retrieve the environment object returned by the getEnvironment function. How can I access this object in another part of my code?
window.MY_EXAMPLE = {
settings : {
local: 'http://localhost:8888/example',
staging_v2: 'http://example.com/staging',
production: 'http://example.com',
image_path: '/images/',
},
fetchEnvironment : function () {
if (window.location.href.indexOf(MY_EXAMPLE.settings.local) > -1) {
var envObj = {
path : MY_EXAMPLE.settings.local + MY_EXAMPLE.settings.image_path,
}
return envObj;
}
if (window.location.href.indexOf(MY_EXAMPLE.settings.staging_v2) > -1) {
var envObj = {
path : MY_EXAMPLE.settings.staging_v2 + MY_EXAMPLE.settings.image_path,
}
return envObj;
}
if (window.location.href.indexOf(MY_EXAMPLE.settings.production) > -1) {
var envObj = {
path : MY_EXAMPLE.settings.production + MY_EXAMPLE.settings.image_path,
}
return envObj;
}
},
}