Created
September 29, 2017 11:16
-
-
Save nengine/e216c080988fca7cf4c3aa26f388f236 to your computer and use it in GitHub Desktop.
vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div id="trades"> | |
<p>{{ message }}</p> | |
<button @click='load'>Load data</button> | |
</div> | |
</template> | |
<script> | |
const Gdax = require('gdax'); | |
const publicClient = new Gdax.PublicClient(); | |
const websocket = new Gdax.WebsocketClient(['LTC-USD']); | |
export default { | |
data: function() { | |
return { | |
message: 'Hello from trades Vue' | |
} | |
}, | |
methods: { | |
mounted: function() { | |
websocket.on('message', data => { | |
console.log(data); | |
}); | |
}, | |
load: function() { | |
publicClient.getProducts((error, response, data) => { | |
if (error) { | |
// handle the error | |
} else { | |
console.log(JSON.stringify(data)); | |
} | |
}); | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment