-
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 exported from 'url' (imported as 'URLSearchParams') #774
Comments
Hey @karanbosamia Do you by chance have a package called Also, what framework are you using? (NextJS, etc). |
I have the same issue, cannot use I do not have |
Hi @gadicc - really nice work here. I am also seeing this error running a next.js client-side component. Interestingly, I still receive data back, unless I have the fetch wrapped in a useEffect() hook. If I keep the call synchronous though, I get data back. I confirmed I don't have any node_modules/url* packages installed. Appreciate any ideas you have. |
Thanks all, for the reports and kind words. I'm just going to be honest here and say that I don't currently have time to look into this further - for now. There are a few big changes in progress (thanks to the awesome our contributor community) that will make it a lot easier to get yf2 running in non-node environments. That will still primarily be denon and v8 for edge computing, because the browser security model has a lot of restrictions, some of which are unsolveable. So, I strongly, strongly recommend in any case, to run yf2 on the server/serverless side. In nextjs this should be as simple as putting it in a server component (i.e., not a client component); however, I haven't tried that myself, and sometimes nextjs's magical bundling can break things. But it definitely works in nextjs api routes, and it's fairly trivial to have the client side call such a route. Trivial if you don't need type safety, at least. For type safety, you'll need something like https://trpc.io/ or here's e.g. a codesandbox without it, I guess we should make something official like that which could be easily imported, but for now, hopefully you'll get the idea `:) If you have questions on the codesandbox, please open another issue for it and I'll be able to explain. You basically get to do this in your client-side React component: const result = useYahooFinance("quote", "TSLA"); |
However, the react server component option really makes the most sense though, so try that first, and if no luck, I'll try do a codesandbox for that too if I get a chance. |
Hi Gadi,
I can look at it in more detail next week if you like. I was able to get around it by creating an internal API that wrapped your component.
Thanks,
Chris
On Jun 15, 2024, at 9:54 AM, Gadi Cohen ***@***.***> wrote:
However, the react server component option really makes the most sense though, so try that first, and if no luck, I'll try do a codesandbox for that too if I get a chance.
—
Reply to this email directly, view it on GitHub<#774 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AB2UOWHGP6ZAOS5A5TYF6ODZHRBP5AVCNFSM6AAAAABHR3D7GSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRZGY4TCMRVHA>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Ah, great! No worries then, as long as you're up and running 🎉 😁 |
@csherida can you explain a little bit in more detail how you achieved to run the library? thanks in advance! |
Sure... I'm using Next.js 14.x (with app routing). Under the API folder, I created an API route. From there, I used useEffect to fetch the data from my API which wrapped yahooFinance2 and formatted the data. I put my code on my GitHub: https://github.com/csherida/next-stock-chart Let me know if it works. Good luck! |
Bug Report
ERROR in ./node_modules/yahoo-finance2/dist/esm/src/env-node.js 5:2-17
export 'URLSearchParams' (imported as 'URLSearchParams') was not found in 'url' (possible exports: Url, format, parse, resolve, resolveObject
Describe the bug
npm start
, the package is blocking with error:Minimal Reproduction
npm start
Environment
Browser or Node: {"react": "^17.0.2"}
Node version (if applicable):
Npm version: "^10.4.0"
Browser verion (if applicable):
Library version (e.g.
1.10.1
):Additional Context
The text was updated successfully, but these errors were encountered: