Tuesday, 30 May 2017

Respodning to GET request with ExpressJS then executing RequestJS request inside

Currently I am just making a call to an API, specifically the Ticket Master Discovery API, and this returns a JSON object just fine:

//PACKAGES 
var express = require('express');
var request = require('request'); 
var router = express.Router(); 


request('https://app.ticketmaster.com/discovery/v2/venues.json?keyword=UCV&apikey=' + apiKey, 
 function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body);
    return;// Print the google web page.
  } 
    else {
      console.log(error); 
  }

});

I would like to utilise ExpressJS's 'get' to respond to a get request and then make a 'request' call (as shown above) inside of that - is this possible or is my understanding incorrect? I've gone ahead and read the documentation, and understand each in their simplest of forms but I'm still struggling.

Thanks



via Zach

No comments:

Post a Comment