bitcoinaverage / api-integration-examples

Bitcoin and Ethereum price API integration examples in csharp, java, nodejs, golang, python, php and ruby
https://apiv2.bitcoinaverage.com/
63 stars 35 forks source link

Unable to build with webpack #15

Closed diadal closed 6 years ago

diadal commented 6 years ago

ERROR in ./node_modules/node-gyp-build/index.js Module not found: Error: Can't resolve 'fs' in '/pcn/node_modules/node-gyp-build' @ ./node_modules/node-gyp-build/index.js 1:9-22 @ ./node_modules/bufferutil/index.js @ ./node_modules/bitcoinaverage/node_modules/ws/lib/buffer-util.js @ ./node_modules/bitcoinaverage/node_modules/ws/lib/receiver.js @ ./node_modules/bitcoinaverage/node_modules/ws/index.js @ ./node_modules/bitcoinaverage/bitcoinaverage/clients/websocket-client.js @ ./node_modules/bitcoinaverage/index.js @ ./resources/assets/js/fx.js @ multi ./resources/assets/js/fx.js

ERROR in ./node_modules/request/lib/har.js Module not found: Error: Can't resolve 'fs' in '/pcn/node_modules/request/lib' @ ./node_modules/request/lib/har.js 3:9-22 @ ./node_modules/request/request.js @ ./node_modules/request/index.js @ ./node_modules/bitcoinaverage/bitcoinaverage/common.js @ ./node_modules/bitcoinaverage/bitcoinaverage/clients/websocket-client.js @ ./node_modules/bitcoinaverage/index.js @ ./resources/assets/js/fx.js @ multi ./resources/assets/js/fx.js

ERROR in ./node_modules/forever-agent/index.js Module not found: Error: Can't resolve 'net' in '/pcn/node_modules/forever-agent' @ ./node_modules/forever-agent/index.js 6:10-24 @ ./node_modules/request/request.js @ ./node_modules/request/index.js @ ./node_modules/bitcoinaverage/bitcoinaverage/common.js @ ./node_modules/bitcoinaverage/bitcoinaverage/clients/websocket-client.js @ ./node_modules/bitcoinaverage/index.js @ ./resources/assets/js/fx.js @ multi ./resources/assets/js/fx.js

ERROR in ./node_modules/tough-cookie/lib/cookie.js Module not found: Error: Can't resolve 'net' in '/pcn/node_modules/tough-cookie/lib' @ ./node_modules/tough-cookie/lib/cookie.js 32:10-24 @ ./node_modules/request/lib/cookies.js @ ./node_modules/request/index.js @ ./node_modules/bitcoinaverage/bitcoinaverage/common.js @ ./node_modules/bitcoinaverage/bitcoinaverage/clients/websocket-client.js @ ./node_modules/bitcoinaverage/index.js @ ./resources/assets/js/fx.js @ multi ./resources/assets/js/fx.js

ERROR in ./node_modules/tunnel-agent/index.js Module not found: Error: Can't resolve 'net' in '/pcn/node_modules/tunnel-agent' @ ./node_modules/tunnel-agent/index.js 3:10-24 @ ./node_modules/request/lib/tunnel.js @ ./node_modules/request/request.js @ ./node_modules/request/index.js @ ./node_modules/bitcoinaverage/bitcoinaverage/common.js @ ./node_modules/bitcoinaverage/bitcoinaverage/clients/websocket-client.js @ ./node_modules/bitcoinaverage/index.js @ ./resources/assets/js/fx.js @ multi ./resources/assets/js/fx.js

ERROR in ./node_modules/forever-agent/index.js Module not found: Error: Can't resolve 'tls' in '/pcn/node_modules/forever-agent' @ ./node_modules/forever-agent/index.js 7:10-24 @ ./node_modules/request/request.js @ ./node_modules/request/index.js @ ./node_modules/bitcoinaverage/bitcoinaverage/common.js @ ./node_modules/bitcoinaverage/bitcoinaverage/clients/websocket-client.js @ ./node_modules/bitcoinaverage/index.js @ ./resources/assets/js/fx.js @ multi ./resources/assets/js/fx.js

ERROR in ./node_modules/tunnel-agent/index.js Module not found: Error: Can't resolve 'tls' in '/pcn/node_modules/tunnel-agent' @ ./node_modules/tunnel-agent/index.js 4:10-24 @ ./node_modules/request/lib/tunnel.js @ ./node_modules/request/request.js @ ./node_modules/request/index.js @ ./node_modules/bitcoinaverage/bitcoinaverage/common.js @ ./node_modules/bitcoinaverage/bitcoinaverage/clients/websocket-client.js @ ./node_modules/bitcoinaverage/index.js @ ./resources/assets/js/fx.js @ multi ./resources/assets/js/fx.js

KolevDarko commented 6 years ago

Hi @diadal , On first glance I'd suggest you take a look at this solution: https://github.com/webpack-contrib/css-loader/issues/447#issuecomment-285600014

If the problem still persists then give us more context on what you are trying to do and what version of node, npm and what OS you are using.

diadal commented 6 years ago

am sock here Failed to load https://apiv2.bitcoinaverage.com/websocket/get_ticket: Request header field X-Signature is not allowed by Access-Control-Allow-Headers in preflight response.

KolevDarko commented 6 years ago

@diadal are you using the npm module on the front end ? It's supposed to be used with NodeJS.

diadal commented 6 years ago

how I dont get explain better

KolevDarko commented 6 years ago

You are supposed to use our API in your server-side (back end) code.

diadal commented 6 years ago
did you have any sample because I follow the instruction

var ba = require('bitcoinaverage');

var publicKey = 'seeds';
var secretKey = 'sdsdsd';

var restClient = ba.restfulClient(publicKey, secretKey);
var wsClient = ba.websocketClient(publicKey, secretKey);

// Here we log the response received by https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCUSD. For custom usage you just need to implement the Anonymous function and do something else instead of console.log(response);.
restClient.tickerGlobalPerSymbol('BTCUSD', function(response) {
    console.log(response);
}, function(error){
    console.log(error);
}) ;

// Here we show an example how to connect to one of our websockets and get periodical update for the Global Price Index for 'BTCUSD'. You can use 'local' instead of 'global', or you can change the crypto-fiat pair to something else (example: ETHEUR), depending on your needs.
wsClient.connectToTickerWebsocket('global', 'BTCUSD', function(response) {
    console.log(response);
}, function(error){
    console.log(error)
}, function(){
    console.log("websocket closed");
});

do I need to run npm build or start or something

KolevDarko commented 6 years ago

Ok here are step by step instructions:

  1. npm install bitcoinaverage
  2. create a js file, server.js and copy the example from above
  3. Create api keys from our website and use them in the example from above
  4. run: node server.js
diadal commented 6 years ago

fix just you guys should include in document