Cypress load data from json – fixture before

I am trying to retrieve some data from a json file via fixture in Cypress, but the data is not recognized at all.

before(() => {
cy.fixture('example').then(function (data) {
    console.log("this", data.user);


The console outputs the user, this is working.

But after that I have a step:

Given("I check data", () => {

And here the data is undefined.

I tried to set inside before also: = data but did not help. I also tried to use beforeEach with no success.

Source: Ask Javascript Questions