Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I access redux store from storage.js? #9814

Open
aquino-luane opened this issue Jan 24, 2025 · 0 comments
Open

How can I access redux store from storage.js? #9814

aquino-luane opened this issue Jan 24, 2025 · 0 comments

Comments

@aquino-luane
Copy link

aquino-luane commented Jan 24, 2025

I want access redux store in the file storage.js, because in the mod I am working we need to send a token (that is stored in redux store) in the API request header to get an asset in the function getAssetGetConfig():

getAssetGetConfig (asset) {
        const mockToken = 'mocked-token';
        return {
            method: 'GET',
            url: `${BASE_API_URL}/md/api/assets/${asset.assetId}.${asset.dataFormat}`,
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${mockToken}`,
            }
        }
    }

I tried creating a HOC that returns the token (see code below) but I was not able to connect it to storage.js. I think is because it is exporting an instance.

const StorageWithToken = withToken(Storage);
const storage = new StorageWithToken();
export default storage;

Thank you 🙇‍♀️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant