Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump axios 1.x [PHX-2740] #1967

Merged
merged 4 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ module.exports = {
globals: {
__VERSION__: require('./package.json').version,
},
moduleNameMapper: {
axios: 'axios/dist/node/axios.cjs',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: What makes this change necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

axios is now published as ESM & CJS - after updating it - jest failed. This fixes it again.

},
}
15 changes: 7 additions & 8 deletions lib/create-contentful-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* different kinds of entities present in Contentful (Entries, Assets, etc).
*/

import { AxiosError } from 'axios'
import { AxiosInstance, createRequestConfig, errorHandler } from 'contentful-sdk-core'
import { GetGlobalOptions } from './create-global-options'
import pagedSync from './paged-sync'
Expand Down Expand Up @@ -104,7 +103,7 @@ export default function createContentfulApi<OptionType extends ChainOptions>(
const response = await http.get(baseUrl + path, config)
return response.data
} catch (error) {
errorHandler(error as AxiosError)
errorHandler(error)
}
}

Expand All @@ -114,7 +113,7 @@ export default function createContentfulApi<OptionType extends ChainOptions>(
const response = await http.post(baseUrl + path, data, config)
return response.data
} catch (error) {
errorHandler(error as AxiosError)
errorHandler(error)
}
}

Expand Down Expand Up @@ -187,7 +186,7 @@ export default function createContentfulApi<OptionType extends ChainOptions>(
throw notFoundError(id)
}
} catch (error) {
errorHandler(error as AxiosError)
errorHandler(error)
}
}

Expand Down Expand Up @@ -239,7 +238,7 @@ export default function createContentfulApi<OptionType extends ChainOptions>(
removeUnresolved: withoutUnresolvableLinks ?? false,
})
} catch (error) {
errorHandler(error as AxiosError)
errorHandler(error)
}
}

Expand Down Expand Up @@ -280,7 +279,7 @@ export default function createContentfulApi<OptionType extends ChainOptions>(
config: createRequestConfig({ query: normalizeSelect(query) }),
})
} catch (error) {
errorHandler(error as AxiosError)
errorHandler(error)
}
}

Expand Down Expand Up @@ -313,7 +312,7 @@ export default function createContentfulApi<OptionType extends ChainOptions>(
config: createRequestConfig({ query: normalizeSearchParameters(normalizeSelect(query)) }),
})
} catch (error) {
errorHandler(error as AxiosError)
errorHandler(error)
}
}

Expand All @@ -340,7 +339,7 @@ export default function createContentfulApi<OptionType extends ChainOptions>(
const currentMaxLifetime = now + ASSET_KEY_MAX_LIFETIME
validateTimestamp('expiresAt', expiresAt, { maximum: currentMaxLifetime, now })
} catch (error) {
errorHandler(error as AxiosError)
errorHandler(error)
}

return post<AssetKey>({
Expand Down
Loading