Skip to content

Commit

Permalink
Compatibility with Axios v1
Browse files Browse the repository at this point in the history
  • Loading branch information
ferferga committed Nov 10, 2022
1 parent a457b4c commit 037a83c
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ import { getAuthorizationHeader } from './utils';
import { getSessionApi } from './utils/api/session-api';
import { getUserApi } from './utils/api/user-api';

// HACK: Axios does not export types for axios/lib. This is a workaround.
type BuildFullPathFunction = (baseURL?: string, requestedURL?: string) => string;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const buildFullPath: BuildFullPathFunction = require('axios/lib/core/buildFullPath');

/** The authorization header field name. */
export const AUTHORIZATION_HEADER = 'Authorization';

Expand Down Expand Up @@ -88,13 +83,10 @@ export class Api {
*/
getItemImageUrl(itemId: string, imageType = ImageType.Primary, params: ImageRequestParameters = {}): string | undefined {
// TODO: We could probably use ImageApiAxiosParamCreator to make this more robust
const uri = this.axiosInstance.getUri({
return this.axiosInstance.getUri({
url: `/Items/${itemId}/Images/${imageType}`,
params
});
// NOTE: This behavior will probably be the default in axios in the future
// https://github.com/axios/axios/issues/2468
return buildFullPath(this.basePath, uri);
}

get authorizationHeader(): string {
Expand Down

0 comments on commit 037a83c

Please sign in to comment.