There are multiple reasons why we would want to mock out a service side API request: local development, offline development, avoid hitting rate limits on third party services and manipulating data for testing. This can be difficult but with the MSWjs library this is straightforward and can easily be integrated with NextJS using the latest instrumentation experimental feature.
If you prefer you can read my blog on this subject here: https://open.substack.com/pub/eddieja...
---
MY BLOG AND NEWSLETTER
For my articles on Open Source as a Contributor and Maintainer, Web Development with Javascript and Typescript, my experience as a freelancer and remote work as a Digital Nomad, Content Creation, Personal Branding and monetising these, check out my Substack: https://eddiejaoude.substack.com
SERVICES I USE AND RECOMMEND
Some of these might be affiliate links but they're no extra cost you and you might get a discount if you sign up.
Live streaming with Streamyard https://streamyard.com/pal/c/61039807...
Cloud hosting with Digital Ocean, you will get $100 FREE credit https://m.do.co/c/c25882c2a61d
Podia host your digital products (PDFs, Videos etc) https://www.podia.com/?via=09d82a
Riverside for recording high quality podcasts https://riverside.fm/?utm_campaign=ca...
---
Mock serverside API requests using NextJS and MSWjs