Prerequisites
Environment check
Node.js version
v18.3.0
Reproduction repository
https://github.com/ajfAfg/msw-operation-research
Reproduction steps
- Run the following commands
git clone https://github.com/ajfAfg/msw-operation-research.git
cd msw-operation-research/nextjs-rest
npm install
npm run dev
- Open http://localhost:3000
Current behavior
In src/pages/index.tsx, getServerSideProps fetches data and outputs the received data to the console. Currently, the output is as follows.
server: {"answer":"yes","forced":false,"image":"https://yesno.wtf/assets/yes/14-b57c6dc03aa15a4b18f53eb50d6197ee.gif"}
The data being fetched here is as follows.
$ curl https://yesno.wtf/api
{"answer":"yes","forced":false,"image":"https://yesno.wtf/assets/yes/11-a23cbde4ae018bbda812d2d8b2b8fc6c.gif"}
Expected behavior
The expected output is as follows, since the request is intercepted by the definition in src/mocks/handlers.ts.
Prerequisites
Environment check
mswversionNode.js version
v18.3.0
Reproduction repository
https://github.com/ajfAfg/msw-operation-research
Reproduction steps
git clone https://github.com/ajfAfg/msw-operation-research.git cd msw-operation-research/nextjs-rest npm install npm run devCurrent behavior
In
src/pages/index.tsx,getServerSidePropsfetches data and outputs the received data to the console. Currently, the output is as follows.server: {"answer":"yes","forced":false,"image":"https://yesno.wtf/assets/yes/14-b57c6dc03aa15a4b18f53eb50d6197ee.gif"}The data being fetched here is as follows.
$ curl https://yesno.wtf/api {"answer":"yes","forced":false,"image":"https://yesno.wtf/assets/yes/11-a23cbde4ae018bbda812d2d8b2b8fc6c.gif"}Expected behavior
The expected output is as follows, since the request is intercepted by the definition in
src/mocks/handlers.ts.server: {"foo":"bar"}