simorgh
simorgh copied to clipboard
Remove `node-fetch`
Reverts bbc/simorgh#11261 and reinstates the original PR: https://github.com/bbc/simorgh/pull/11122
Description from original PR:
Overall changes
Removes node-fetch and isomorphic-fetch in favour of using Node 18+ built-in fetch mechanism, provided by undici. Removes the need to do https://github.com/bbc/simorgh/pull/9611
undici has been added as a dependency as we need its Agent constructor to use our custom certs to authenticate requests.
This aligns the Express and Next.js app to use the same fetch mechanism across both apps, and removes the need to keep node-fetch updated through its transition to ESM.
Code changes
- Remove
node-fetchandisomorphic-fetchand the instances these libraries were imported - Consolidate the
getAgentfunction across the Express and Next.js apps - Mock
AgentandgetAgentin tests - Refactors the Live page fetch to be more inline with other fetchers that use
fetchDataFromBFF
Testing
- Pull down this branch locally
- Run
yarnto install the new dependencies - Run
yarn dev - Visit a url with the
renderer_env=liveflag to ensure it fetches Live data with the certs - Confirm the page loads as expected
- Repeat the steps for the Next.js app