Skip to content

Is there a way to redo a request if failed? #321

@extralsc

Description

@extralsc

Hello,

Basiclly I wounder if there is a way to insert the config of a older request in a new one?

For example:

apiClient.addAsyncResponseTransform(async (response) => {
    console.log("Response after request: ", response);

    const prevRequest = response?.config;

    if (response.data.status == "expiredToken" && response.status === 403 && !prevRequest?.sent) {
        prevRequest.sent = true;

        const newAccessTokenResponse = await apiClient.get("/refresh");
        const newAccessToken = newAccessTokenResponse.data.accessToken;
        
        prevRequest.headers["authorization"] = "Bearer " + newAccessToken;
        
        **--> // MAKE NEW REQUEST HERE WITH SAME CONFIG AS OLD ONE? apiConfig.config(prevRequest) or something?**
    }

});

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