Closed dolbex closed 3 years ago
This looks like a known issue with some frameworks that cannot import the URLSearchParams
object.
We might be able to get wiki
working without using this object. Will need some more investigation.
On pure js
and node
the constructor works but it does not work for frameworks like Vue
or React
Is this something I could pitch in with?
I looked at the issue you linked to and I get the gist of it. If you could give me any tips on how to approach the problem, I have time this week to work on it.
Thanks for the offer @friendofdog .
I am currently unsure on how to go about solving this issue. We could take one of either ways.
URLSearchParams
object, and find some other way to get queries working for wiki.Helpful links could be this one on swagger, this one on stack overflow.
Also, this only seems to happen to older node versions <8
or <10
. If that's the case, it might not be worth fixing considering node v10 is under manintainence and a lot of libraries are dropping support for the same.
I haven't had the time to debug and reproduce this issue. The first step would definitely be that.
@dolbex , could you tell us the node version and the vue version you are encountering this error for?
@dopecodez - I'm running node v14.16.0 and for this particular project nuxt 2.15.2 and vue 2.6.12
@dolbex Many thanks for providing details.
I reproduced this error using Node 15.5.1 and Vue 2.6.11. I went over the links you provided but none of the proposed solutions seem to have any effect.
I looked at the built file for requests.js
in dist
. It imports url
as const url_1 = require("url");
. But if you console log url_1
, it's almost empty. The URLSearchParams
method is not there.
I'm not sure why url
isn't being required properly. Seems like a very straightforward import to me.
The url
import fails because its a node js object @friendofdog and not available in the browser.
I think this issue can be treated as a broader wiki
does not work with any of the FE js frameworks because of the node specific functions we are using.
I played around with this issue as well. While we can get wiki
to work using the encodeURI
function there are still more issues with making it browser compatible.
Everything seems to be working fine and you can check this out in #16. The main thing i still need to test is #12 and then we can think about if this would be a good release.
For anyone still looking at this, https://github.com/dopecodez/Wikipedia/releases/tag/v1.1.0 is published and this version will be the new browser compatible version of wikipedia
.
I'm currently working on a Vue application that has the following method
Unfortunately it returns this exception: