You are returning a function there, since you can grab the value by invoking this function and assigning it a variable.
import getLink from './link';
const url = getLink();
const linkUrl= `${url}/food/new`;
Also, with this code actually you can't export your function like that for arrow functions. If you use default
then you shouldn't use a name in your function declaration to export your function.
Instead use:
export default () => {
const url = 'http://www.foo.com'
return url;
};
or first assign it to a variable then use default:
const getLink = () => {
const url = 'http://www.foo.com'
return url;
};
export default getLink;
One other alternative is using a named export instead of default
.
export const getLink = () => {
const url = 'http://www.foo.com'
return url;
}
then import it like:
import { getLink } from "/.link";