TypeError: Cannot read property 'fetch' of undefined
See original GitHub issueWhen trying to add a RESTDataSource all requests made within this class fail.
Why is this?
The link belows allows you to test the code i wrote. CodeSandBox Link Version: latest
Expected behaviour
Being able to make a get Request to the dummy API
Actual behaviour
Request fails with the following error:
"errors": [ { "message": "Cannot read property 'fetch' of undefined", "locations": [ { "line": 2, "column": 3 } ], "path": [ "hello" ], "extensions": { "code": "INTERNAL_SERVER_ERROR", "exception": { "stacktrace": [ "TypeError: Cannot read property 'fetch' of undefined", " at API.<anonymous> (/sandbox/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:158:63)", " at Generator.next (<anonymous>)", " at /sandbox/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:8:71", " at new Promise (<anonymous>)", " at __awaiter (/sandbox/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:4:12)", " at trace (/sandbox/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:153:78)", " at API.<anonymous> (/sandbox/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:196:24)", " at Generator.next (<anonymous>)", " at /sandbox/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:8:71", " at new Promise (<anonymous>)" ] } } } ], "data": { "hello": null } }
When logging this
in the API class this is the result:
API { httpFetch: undefined, memoizedResults: Map {}, baseURL: 'https://jsonplaceholder.typicode.com/' }
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top GitHub Comments
Same here. If can help :
Hey @experimentalPrivateRepos, thanks for submitting an issue (and especially the reproduction!)
I forked your sandbox and found that removing the
initialize
override, or restoring it to the same behavior as theRESTDataSource
resolved the issue.