I am writing an react-app where I need to fetch some data from another website.
const getUserData = (id, key, access_token, getWith) => {...}
This functions fetches the data from the external source and is exported like this:
module.exports = {
getUserData,
};
The function is then used in another file like this:
import {getUserData} from '../Logic/userLogic.js'
fetchData(){
const thenFunc = (arr, userType) => {
let newUser = userType;
arr.forEach(element => {
newUser = merge(newUser, element)
})
return newUser
}
getUserData(this.state.user.id_, ['display_name', 'profile_image_url'],this.state.user.access_token, 'id')
.then(arr => {
this.setState({user: thenFunc(arr, this.state.user)});
}
}
If I start the react-app everything works fine but if I want to build the website I get the error:
Attempted import error: 'getUserData' is not exported from '../Logic/userLogic.js'.