Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require('axios');
  2.  
  3. class Bee {
  4.  
  5.     constructor(token) {
  6.  
  7.         this._headers = {
  8.             'WWW-Authenticate': 'Token',
  9.             'Authorization': 'Token '+ token,
  10.             'Accept': 'application/json',
  11.             'Content-Type': 'application/json'
  12.         }
  13.  
  14.         this._api = axios.create({
  15.             baseURL: 'http://127.0.0.1:8080/api/',
  16.             headers: this._headers
  17.         });
  18.        
  19.     }
  20.  
  21.     async  _execute(endpoint, array) {
  22.         let response = await this._api.post(endpoint, {
  23.             params: array
  24.         });
  25.  
  26.         console.log(response.data)
  27.  
  28.         return response.data
  29.     }
  30.  
  31.     balance(coin = '') {
  32.         return this._execute('balance', {coin: coin})
  33.     }
  34. }
  35.  
  36. (async () => {
  37.     const bee = new Bee('848010cf036b7cce0f98d942b504320b58586902')
  38.  
  39.     console.log(await bee.balance())
  40. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement