i make an api request to get the token and use it in another function in a seprate file, when i export the token from one file to another it is not working as expected , the activat user method can not read the token
my code in one file
class User {
user_T= ''
getaccessToken(){
cy.request({
method: 'POST',
url: 'url',
form: true,
body: {
"username": .,..
"password": ....
}
})
.then( response=> {
return this.user_T= response.body.Token;
})
}
}
export default new User
the other file is
import User from './user'
const token= new User()
it.only('activate user', () => {
cy.request({
method: "POST",
url: 'url/activate',
headers: {
'Authorization' : 'Bearer ' + token.user_T,
},
body:{
"test": 'test'
}
})
})