Closed 0x520x650x78 closed 2 years ago
In the webpack config, the library is packaged as a global under the name ftxapi
when loaded in the browser:
https://github.com/tiagosiebler/ftx-api/blob/master/webpack/webpack.config.js#L12
You should be able to do something like
<script type="module" src="./src/ftxapi.js"></script>
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
const { RestClient } = ftxapi;// or window.ftxapi
const test_client = new RestClient(credential.test[0], credential.test[1], {subAccountName: 'test'});
In the webpack config, the library is packaged as a global under the name
ftxapi
when loaded in the browser: https://github.com/tiagosiebler/ftx-api/blob/master/webpack/webpack.config.js#L12You should be able to do something like
<script type="module" src="./src/ftxapi.js"></script> <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script> const { RestClient } = ftxapi;// or window.ftxapi const test_client = new RestClient(credential.test[0], credential.test[1], {subAccountName: 'test'});
Thanks for the help. When I define the restclient in this way and run it I get a network error.
However, when I run the with the same key and secret with nodejs, it seems to work out fine.
Could it be CORS? You could try to catch the exception and logging it for more detail, and/or check the network tab in your browser's dev tools to see what request happened and if it failed.
RE cors, lots of context about it in a thread in my bybit connector: https://github.com/tiagosiebler/bybit-api/issues/79
OK I will take a look and update the progress I make here. (Maybe a pull request if I spot where the issue is)
Thanks for the reference and the great package.
OK I found the issue. It is the CORs problem and since I'm using the browser for the dashboard, I just need to allow all CORs and then the issue will be resolved.
I encountered this error while trying to integrate this package in browser. After running webpack and put it in browser script, I got ReferenceError: RestClient is not defined error.
Below is a snippet of code that I run:
const test_client = new RestClient(credential.test[0], credential.test[1], {subAccountName: 'test'});
The webpacked .js file is as following: https://gist.githubusercontent.com/0x520x650x78/cc6538ac9c6b913ac4ebba72a876c0df/raw/cd0f4f2afaf8b129341e2f7855ccb18615f7c9b8/ftxapi
Thanks!