-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Error: invalid json response with provider.getEtherPrice() function #776
Comments
If I hit the api url I get:
I'll look into updating this asap. |
Also, quick question, are you using ethers v4 or the v5 beta? |
@ricmoo Yes, if you in your browser directly put the url it gives you the expected response. But that is with the Etherscan Api itself, what happend with ethers.js that gives me that response? how can I do? the only thing that I think of is instead of obtaining a json, obtaining a text, but how can I do that from ethers.js? Also is as the network property I give 'ropsten' or another testnet instead of 'homestead' as the mainnet. Returns 0, that is correct because the price is 0$ |
@Gabriel1590 What version of ethers are you using? It looks like it should work fine in v4, so I just want to confirm you are using v5. |
@ricmoo ethers: ^4.0.46 |
Yes, if it is not on mainnet, it does not even query any API, it just returns 0. :) When I try v4.0.46 it works fine for me, even if I hit it repeatedly. What if you try v5? Maybe the environment you are using has a less-than-ideal XMLHttpRequest implementation? In v5, it uses the fetch API instead. I'm not sure what |
@ricmoo could you tell me the exact code that you´re implementing? |
(oh but v5 has a bug in that call; fixing it now) |
For v4? This is the code |
And this is what I run to use it:
|
@ricmoo I´ll try with the V5, give me a moment to download it. I´m getting network issues |
The v5 test cases are still running. I'll publish once they pass. |
Make sure you get |
@ricmoo my app doesn´t work. It gives me this error:
when I tried to initialize the app |
What version of TypeScript are you using? I think you need to bump the version to 3.8, since the new TypeScript definition files use a getter in the interface file for readonly variables. |
@ricmoo I´m using Typescript 3.7.5 |
That should be a recent enough version. This breaking change was added in 3.7. Here is more info on it. Can you run You can also try cleaning your build, and re-running npm install and build? |
yes, it is 3.7.5. I already do that, but it doesnt work. The only think that does not work is the getEtherPrice(), the rest functions works properly. I solved it using the coingecko API, but i´ll like to use only ethers.js to all operations relate to Ethers |
Looks like your error may be a combination of the version of Angular and TypeScript. Here is someone with the same issue as you: storybookjs/storybook#9463 Maybe that will help? |
Did that issue help? |
@ricmoo I'm sorry for the late response. I have not prove it. As I've been reading, It may be an error from TypeScript, but in this moment I have not The time to solve It. As soon as I Fix it, I'll upload The solution. Thank You for The help, I'll ask You again if I need some help |
Ok. I'm going to close this ticket then, since the bug you identified in v5 has been resolved, and I think v4 should work fine once the TypeScript things are figured out. But if you still have problems once the TypeScript stuff is sorted, feel free to re-open or open new issue. Sound good? Thanks! :) |
@ricmoo I solve The problem, I just pass to a backend service with NodeJs and TypeScript, and doing API Request to The info I need and It works perfectly. Thanks for allí The help |
I am trying to use the getEtherPrice() in v5.6.8, but getting an "not implemented" error. Is there plan to implement this function in the near future? Thanks! |
@dannybin What provider are you using? This is currently only available in the EtherscanProvider, as it is the only service which offers an RPC for it. |
Thank you! I was using infura. will try with ethanscan. |
I´m trying to obtain the Ether Price using ether.js. I tried to do it calling the function etherscanProvider.getEtherPrice()
And gives me this err:
Error: invalid json response at XMLHttpRequest.o.onreadystatechange [as __zone_symbol__ON_PROPERTYreadystatechange] (ethers.min.js:1) at XMLHttpRequest.wrapFn (zone-evergreen.js:1191) at ZoneDelegate.invokeTask (zone-evergreen.js:391) at Object.onInvokeTask (core.js:39680) at ZoneDelegate.invokeTask (zone-evergreen.js:390) at Zone.runTask (zone-evergreen.js:168) at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:465) at invokeTask (zone-evergreen.js:1603) at XMLHttpRequest.globalZoneAwareCallback (zone-evergreen.js:1629)
I also tried to call directly the api of etherscan:
And its returning
null
Also tried to call the etherscan api directly from the browser console, and also returns
null
Typescript 3.7.5
Angular 8.3.23
Node 12.16.1
Ionic 5.4.15
The text was updated successfully, but these errors were encountered: