I'm returning a Promise
from this function
const liab_config = () => {
return axios.get(`${config.server_url}/fetch_config_liab`);
}
export default { liab_config }
And trying to handle the Promise
inside another file
import liab_config from './utils/kc-adapter'
function set_liab_config(){
liab_config().then((response) => {
if(response.data.success){
let { kc_config_liab } = response.data;
return kc_config_liab['auth-server-url'];
}
else
return null;
}).catch(ex =>
console.log(ex));
}
Here I'm getting the error as:
Uncaught TypeError: Object(...) is not a function
on line liab_config().then((response)
. What could be the reason?
You're default-exporting an object literal. You want to use either a named export
const liab_config = …;
export { liab_config as liab_config }
// shorter:
const liab_config = …;
export { liab_config }
// or just:
export const liab_config = …;
with
import { liab_config } from './utils/kc-adapter'
or a default export
const liab_config = …;
export { liab_config as default }
// or just:
default export const liab_config = …;
// or without the local name:
default export …;
with
import liab_config from './utils/kc-adapter'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With