diff --git a/packages/gatsby-source-contentful/src/__tests__/fetch-network-errors.js b/packages/gatsby-source-contentful/src/__tests__/fetch-network-errors.js index 27c7045dadd87..8f3d0a2db687a 100644 --- a/packages/gatsby-source-contentful/src/__tests__/fetch-network-errors.js +++ b/packages/gatsby-source-contentful/src/__tests__/fetch-network-errors.js @@ -57,17 +57,17 @@ describe(`fetch-retry`, () => { .reply(200, { items: [{ code: `en`, default: true }] }) // Sync .get( - `/spaces/${options.spaceId}/environments/master/sync?initial=true&limit=100` + `/spaces/${options.spaceId}/environments/master/sync?initial=true&limit=1000` ) .times(1) .replyWithError({ code: `ETIMEDOUT` }) .get( - `/spaces/${options.spaceId}/environments/master/sync?initial=true&limit=100` + `/spaces/${options.spaceId}/environments/master/sync?initial=true&limit=1000` ) .reply(200, { items: [] }) // Content types .get( - `/spaces/${options.spaceId}/environments/master/content_types?skip=0&limit=100&order=sys.createdAt` + `/spaces/${options.spaceId}/environments/master/content_types?skip=0&limit=1000&order=sys.createdAt` ) .reply(200, { items: [] }) @@ -90,7 +90,7 @@ describe(`fetch-retry`, () => { .reply(200, { items: [{ code: `en`, default: true }] }) // Sync .get( - `/spaces/${options.spaceId}/environments/master/sync?initial=true&limit=100` + `/spaces/${options.spaceId}/environments/master/sync?initial=true&limit=1000` ) .times(3) .reply( diff --git a/packages/gatsby-source-contentful/src/__tests__/fetch.js b/packages/gatsby-source-contentful/src/__tests__/fetch.js index 4ef6d088992cc..4db1998618cf4 100644 --- a/packages/gatsby-source-contentful/src/__tests__/fetch.js +++ b/packages/gatsby-source-contentful/src/__tests__/fetch.js @@ -255,7 +255,7 @@ describe(`Displays troubleshooting tips and detailed plugin options on contentfu it(`API 404 response handling`, async () => { mockClient.getLocales.mockImplementation(() => { const err = new Error(`error`) - err.responseData = { status: 404 } + err.status = 404 throw err }) @@ -295,7 +295,7 @@ describe(`Displays troubleshooting tips and detailed plugin options on contentfu it(`API authorization error handling`, async () => { mockClient.getLocales.mockImplementation(() => { const err = new Error(`error`) - err.responseData = { status: 401 } + err.status = 401 throw err }) diff --git a/packages/gatsby-source-contentful/src/fetch.js b/packages/gatsby-source-contentful/src/fetch.js index a42e6d55ab456..31aa77273a409 100644 --- a/packages/gatsby-source-contentful/src/fetch.js +++ b/packages/gatsby-source-contentful/src/fetch.js @@ -159,8 +159,8 @@ module.exports = async function contentfulFetch({ sourceMessage: `We couldn't make a secure connection to your contentful space. Please check if you have any self-signed SSL certificates installed.`, }, }) - } else if (e.responseData) { - if (e.responseData.status === 404) { + } else if (e.status) { + if (e.status === 404) { // host and space used to generate url details = `Endpoint not found. Check if ${chalk.yellow( `host` @@ -169,7 +169,7 @@ module.exports = async function contentfulFetch({ host: `Check if setting is correct`, spaceId: `Check if setting is correct`, } - } else if (e.responseData.status === 401) { + } else if (e.status === 401) { // authorization error details = `Authorization error. Check if ${chalk.yellow( `accessToken` @@ -222,7 +222,7 @@ ${formatPluginOptionsForCLI(pluginConfig.getOriginalPluginOptions(), errors)}`, } catch (e) { // Back off page limit if responses content length exceeds Contentfuls limits. if ( - e.responseData.data.message.includes(`Response size too big`) && + e.response?.data?.message.includes(`Response size too big`) && currentPageLimit > 1 ) { lastCurrentPageLimit = currentPageLimit