-
Notifications
You must be signed in to change notification settings - Fork 62
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
URLSearchParams is not a constructor - Next.js, React #771
Comments
Hey, I need to look into this further, and figure out what's going wrong where, as obviously In the meantime however, wanted to make sure you saw the warning about running yf2 in the browser in the README. For example, your code above won't work as it will be blocked by a CORS request. Also - not mentioned in the README yet - but more and more parts of yahoo finance are going behind a cookie-and-crumb wall, which currently will just break altogether in the browser. We may well remove browser support completely in the future. Anyway, I'll get back to you on this issue when I have a chance but I strongly, strongly, strongly recommend to not try do this on the browser side. Rather have the client access an API route which does the actual yf2 invocation. If it's not clear how to do this, I'll try setup an example on codesandbox (P.S. unfortunately your shortened link did actually route through to csb `:). |
Hi @gadicc , I fixed the URL, and also did another example in Node.js which works. So you will suggest making a Node API and not to use SSR language? Thanks for your quick reply! Node CodeSandbox: https://codesandbox.io/p/devbox/festive-dewdney-7ysrcn |
Ah amazing, great job! And my pleasure. Yeah, Node is best. But, RSCs should work fine, even though I never tried. If you're using Next's app router, should be enough to drop the But yeah, if you're already using the Node API and everything is working, up to you. I haven't actually ever tried the RSC way. |
Bug Report
Describe the bug
Unable to call the API in Next.js, Unhandled Runtime Error
Error: Failed to fetch dividend data: URLSearchParams is not a constructor
Minimal Reproduction
CodeSandbox url: https://codesandbox.io/p/devbox/pedantic-herschel-s39y95?embed=1&file=%2Fapp%2Fpage.tsx
Environment
The text was updated successfully, but these errors were encountered: