Skip to content

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

Open
@aquino-luane

Description

@aquino-luane

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 🙇‍♀️

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions