Getting fetch not defined error[Question]
swamy2712 opened this issue · 1 comments
swamy2712 commented
System Environment
- OS: Windows 10
- NodeJS Version: 14.17.0
- This LIbrary Version: 2.20.1
Question Description
I'm getting ReferenceError: fetch is not defined when I try to use client.newRequest API as shown below.
The error happens when line 32 is executed in @OData\client\lib\request.js:32 file.
I addedconst fetch = require("node-fetch");
line in @OData\client\lib\request.js file and error was resolved. I'm not sure what is the problem, can anyone please help me to resolve this issue ?
Soontao commented
hi @swamy2712
have a look at this doc, it should work with nodejs
https://github.com/Soontao/light-odata/blob/main/docs/Advanced.md#server-side-polyfill
// import "@odata/client/lib/polyfill"
require("@odata/client/lib/polyfill")
// use OData