Skip to content

Optional headers #7

Closed
Closed
@mmarrius

Description

@mmarrius

If your config looked something like this in v 0.x

        const config = {
            baseURL: baseUrl,
            method: 'GET',
            headers: accessToken && { Authorization: "Bearer " + accessToken }
        }

know that if accessToken is false it will end up with a header name must be a non-empty string error in v 1.x
You can remove the extra check of accessToken && in which case the header's value will become Bearer false. Having the header present however, means that the request is not public anymore so the better solution would be to not send the header at all, in case you don't have the token.

        const config = {
            baseURL: baseUrl,
            method: 'GET',
        }

        if (accessToken) {
            config.headers = { Authorization: "Bearer " + accessToken }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions