Skip to content

createAuthRefreshInterceptor is not a function #290

Open
@tomerh2001

Description

import createAuthRefreshInterceptor from 'axios-auth-refresh';

const authToken = Buffer.from(`${aws.production!.outbrain.user}:${aws.production!.outbrain.password}`).toString('base64');
const fetchAccessToken = cachedFunction(OutbrainUtils.fetchAccessToken);

const client = axios.create({
	baseURL: `${aws.production!.outbrain.urlApi}${context.user!}`,
	timeout: moment.duration(10, 'second').asMilliseconds(),
});

const refreshAccessToken = async (failedRequest: AxiosError) => {
	await invalidateCache(fetchAccessToken, [authToken]);
	const accessToken = await fetchAccessToken(authToken) as CachedFunctionResult<Promise<string>>;
	failedRequest.config!.headers['OB-TOKEN-V1'] = await accessToken.result;
	return client.request(failedRequest.config!);
};

createAuthRefreshInterceptor(client, refreshAccessToken, {statusCodes: [StatusCodes.UNAUTHORIZED]});
client.interceptors.request.use(async request => {
	const accessToken = await fetchAccessToken(authToken) as CachedFunctionResult<Promise<string>>;
	request.headers['OB-TOKEN-V1'] = await accessToken.result;
	return request;
});
return client;

But I get ERROR: createAuthRefreshInterceptor is not a function.

This is the version in my package.json:

    "axios-auth-refresh": "^3.3.6",

What am I missing?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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