Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"fetcher is not a function" - React #212

Closed
MikyStar opened this issue Jul 12, 2019 · 6 comments
Closed

"fetcher is not a function" - React #212

MikyStar opened this issue Jul 12, 2019 · 6 comments

Comments

@MikyStar
Copy link

Description

After having wired up my React JSS to my Sitecore instance, I tried fetching data from it like the documentation said but I encountered an error "TypeError: fetcher is not a function" within node_modules/@sitecore-jss/sitecore-jss/dist/dataApi.js:90.

Expected behavior

Feteching datas from my Sitecore instance.

Steps To Reproduce

Nothing more than a default HelloWorld React app made with

jss create my-first-jss-app react

Then I added a basic React class component and added the very same lines (different token though) as the documentation within a componentDidMount function.

Your Environment

  • Sitecore Version: 9.0.1
  • JSS Version: 11.0.2
  • Browser Name and version: Chrome 75.0.3770.100 (Build officiel) (64 bits)
  • Operating System and version (desktop or mobile): MS Windows Server 2016 (10.0.14393)
@kamsar
Copy link
Contributor

kamsar commented Jul 12, 2019

The React default fetcher is defined here and then passed into the layout data api here. The fetcher allows you to customize the library used to make HTTP calls to Sitecore.

It sounds like your fetcher is null or not a function in the RouteHandler.js.

@MikyStar
Copy link
Author

Am I supposed to implement it on my side?

@kamsar
Copy link
Contributor

kamsar commented Jul 15, 2019

No, it should be wired up out of the box and work fine. But that is the mechanism you seem to be having trouble with so I'm trying to point you to the right places to be troubleshooting the problem.

@MikyStar
Copy link
Author

I checked that my setup provides the same code as you pointed me to and it does
I tried reinstalling my node_modules but the error is still there

@MikyStar
Copy link
Author

It seems like the dataApi.js file is expecting me to provide a fetcher attribute inside the fetchOptions object described in the documentation page linked above, however it doesn't speaks about it

JamieKDonnelly added a commit to JamieKDonnelly/jss that referenced this issue Dec 19, 2019
Updating documentation to resolve issues mentioned in Sitecore#212 and Sitecore#253
sc-antonkulagin added a commit that referenced this issue Jan 29, 2020
@sc-antonkulagin
Copy link
Contributor

@MikyStar This issue was described by merging #306. If you feel that additional information is needed, feel free to reopen this issue or create a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants