Skip to content

Automatic fetch replacement #672

Answered by Xunnamius
linas-deliveroo asked this question in Q&A
Discussion options

You must be logged in to vote

NextApiRequest and NextApiResponse are TypeScript types, not classes. They don't actually exist, so you can't create new instances of them. You're actually dealing with IncomingMessage and ServerResponse instances (respectively) with methods added by the Next.js API resolver. The purpose of NTARH is to pull this resolver out of Next.js's source code and run it for you (i.e. your handlers receive objects satisfying the NextApiRequest and NextApiResponse type definitions) just by calling the extremely convenient testApiHandler function.

From what you describe, it sounds like you want to use something like Mock Service Worker (MSW), which is compatible with NTARH. You can use MSW to capture …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@linas-deliveroo
Comment options

Answer selected by linas-deliveroo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants