Closed tommaso-bissoli closed 5 days ago
Hi, @tommaso-bissoli.
It looks like you've found this library through the window in the past. It used to be called node-request-interceptor
but that package is a few years old now.
You have two options:
@mswjs/interceptors
instead (this library). msw
directly, which is more developer-friendly, especially if you are not deeply familiar with Node.js. This library, Interceptors, is primarily designed as a low-level solutions for developers to build their own API mocking libraries. I highly recommend you use https://mswjs.io/ instead.
Hi,
first of all: I'm quite ignorant on Node JS. I do not kwno if I'm doing right.
MY GOAL I want to intercept a fetch inside my React app before it can do anything. I searched and found Node Request Interceptor could be the solution.
This is the filsystem structure:
src/ middleware/
Inside I created intercept.js with this simple code:
Inside package.json I have this script:
In the terminal when I run
npm run intercept
I get this error:All the urls to the node module in the error log are correct aside the fact that the real file system structure is this:
node_modules/ node-request-interceptor/ bin/
with inside of bin folder: presets/ or interceptors/.
The "bin/" part is missing in the import but even adding it the error still logs.
What I'm doing wrong? What I'm missing?
Thank you.