Wednesday 7 June 2017

printing api response on browser

I'm absolute beginner on nodejs or javascript so excuse me for the low level question. I read a few tutorials but couldn't find a way to print out the response on the browser (i'm using ejs) what I can get is I can get it printed on console but I don't have a no clue on how to do it. Could someone direct me to the right way or show me a snippet so i can learn from it?

the way i'm getting the console log result is:

const express = require('express')
const app = express()
const bcypher = require('blockcypher')
const request = require('request');

app.set('view engine', 'ejs');

request('https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD/balance', function (error, response, data) {
  if (!error && response.statusCode == 200) {
    console.log('data')
  }
})

app.listen(3000, function() {
  console.log('listening on 3000')
})

thank you



via Enkhtuvshin

No comments:

Post a Comment