Skip to content

Commit

Permalink
Merge pull request #1967 from contentful/chore/bump-axios-1.x
Browse files Browse the repository at this point in the history
fix: bump axios 1.x [PHX-2740]
  • Loading branch information
mayakarabula authored Jul 31, 2023
2 parents 5462ba0 + 0c420a5 commit d497590
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 176 deletions.
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',
},
}
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

0 comments on commit d497590

Please sign in to comment.