Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const axios = require('axios');
- class Bee {
- constructor(token) {
- this._headers = {
- 'WWW-Authenticate': 'Token',
- 'Authorization': 'Token '+ token,
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- }
- this._api = axios.create({
- baseURL: 'http://127.0.0.1:8080/api/',
- headers: this._headers
- });
- }
- async _execute(endpoint, array) {
- let response = await this._api.post(endpoint, {
- params: array
- });
- console.log(response.data)
- return response.data
- }
- balance(coin = '') {
- return this._execute('balance', {coin: coin})
- }
- }
- (async () => {
- const bee = new Bee('848010cf036b7cce0f98d942b504320b58586902')
- console.log(await bee.balance())
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement