I'm trying to use the user function from that.
class GlobalParams {
constructor() {
this.user = '';
}
user = (user) => {
if(!user) return this.user;
this.user = user;
}
}
export default gp = new GlobalParams();
And use it in state as - user: gp.user(), but it says that 'user' is not exported.
Request:
getUserData() {
fetch(`${API}/auth/user`, {
method: 'GET',
withCredentials: true,
credentials: 'include'
})
.then (response => response.json())
.then (response => {
gp.setUser(response)
})
.catch (error => {
console.error (error);
});
}