I'm built and REST API and now I'm trying to consuming it. I'm using fetch as the same way that it's used in JS. Example: JS: fetch example
I'm working with express and typescript, this is my tsconfig if it can help: tsconfig
I'm trying to do the same call that is in JS in my server.ts: server.ts
But I'm having this error:
ReferenceError: exports is not defined.
I've trying to resolve the problem, I've checked lot of websites but I didn't find a good solution.
I find once that is to put "type":"module" in the package.json after install node-fetch module because it need it to be imported well. But should be something else that I'm missing right now related to configuration (commonjs, babel or something...)
Thank you.
This is the error that I'm getting if I use fetch (no "type":"module" in package.json). Is different to the previouse one where I have the "type":"module" in the package.json